I’m using freertos 8.2.3, and I meet a problem of xSemaphore.
I used xSemaphore successful in one of my project. but when I use it the same way in another project, it failed to give semaphore. the latter project is derived from the former one. and I compared FreeRTOSConfig.h in the two project, they are the same.
the program stopped at xSemaphoreGiveFromISR. any other factor can influence semaphore?
What do you mean with a “timer fired handler”? Is that a hardware timer causing an ISR?
Or is that a handler that is called from the timer module?
And if so, I think you should use xSemaphoreGive() because the code runs in the context of the timer task.
Maybe the code stops in a configASSERT(), have you checked that?
I’m using freertos 8.2.3
That version works perfectly, but it is recommended to use the latest version for new developments.
Sounds like an interrupt priority issue of the timer. Did you call NVIC_SetPriority with an appropriate priority somewhere ?
In addition please see this
and Richard’s follow up.
You should better not define global variables like data_ready_sem in a header file.
Just declare it extern SemaphoreHandle_t data_ready_sem; and define it in one c-file if you want to use it (as a global variable) in multiple c-files later on.
If it’s intended use is limited to a single c-file (e.g. the timer driver/task module) better define it as static SemaphoreHandle_t data_ready_sem; in this c-file.
Just a hint and to avoid unexpected ‘multiple definitions’ errors if you include the header file in another c-file later on.