Function call From a Task Generating ERROR

sangeo949 wrote on Sunday, August 25, 2019:

Hai all i am new in Freertos… Now i am developing a program with 2 tasks it is working fine but when i am add one function inside the task keil mdk(4) generating an error . I am totally confused about this… is it possible to use a function inside the task?
My Code is as below
void Normal_Control_(void const * argument)
{
void saneesh();
int output;
int ct;
/// MyFunction is below/////
static void saneesh()
{
ct=0;
}
///// MyFunction ending here/////

/* Infinite loop /
for(;:wink:
{
osSemaphoreWait(Voltage_CTRLHandle,1);
output=voltage;
osSemaphoreRelease(Voltage_CTRLHandle);
sprintf(msg, “%d\r\n”,output);
HAL_UART_Transmit(&huart2,(uint8_t
)msg,20,100);
osDelay(2000);
}
}

Generating error is …/Src/main.c(436): error: #65: expected a “;”
…/Src/main.c(508): error: #169: expected a declaration
Actually there is nothing to cause such an error;
If I delete that function then program is working fine

Please help me…
Thanks in advance

hs2sf wrote on Sunday, August 25, 2019:

It’s simply a C syntax error completely unrelated to tasks or something.
Define your function e.g. just above Normal_Control_ function optionally with a preceeding declaration.
A task is a FreeRTOS runtime feature but the task main function is just a C-function following a few additional rules required by FreeRTOS as e.g. should not return etc.

rtel wrote on Sunday, August 25, 2019:

This is just a compiler build error as you have invalid C syntax
somewhere in your code - completely unrelated to FreeRTOS.

sangeo949 wrote on Tuesday, August 27, 2019:

Thanks a lot Mr. HS2 and Mr. Richard Barry for your time and Consideration. The problem is solved when I put that function just above the task as Mr.HS2 Suggests. Thank you Very much

sangeo949 wrote on Tuesday, August 27, 2019:

Thanks a lot Mr. HS2 for your time and Consideration. The problem is solved when I put that function just above the task as you said. Thank you Very much

sangeo949 wrote on Tuesday, August 27, 2019:

Thanks a lot Mr. HS2 for your time and Consideration. The problem is solved when I put that function just above the task as you said. Thank you Very much