Hello,
Since I started using FreeRTOS I had this weird behavior ( or it’s normal).
I create a semaphore (Rx_Semaphore), then i use this semaphore to block a task (Task0) with it.
And another task (task1) to give Rx_Semaphore.
When I run my code, Task0 takes Rx_Semaphore even if task1 didn’t give Rx_Semaphore yet.
The solution I use is to take Rx_Semaphore (xSemaphoreTake(Rx_Semaphore ,0) in the first task that will run.
Is this a normal behavior or I’m missing something ?
If you look at the vSemaphoreCreateBinary() macro you will see the
initial state for the semaphore.
Assuming you are using a recent version of FreeRTOS it is recommended to
use xSemaphoreCreateBinary() in place of vSemaphoreCreateBinary(). When
using the ‘x’ function rather than the ‘v’ macro the semaphore will not
be available until it has first been given.