Here I am using binary a semaphore to protect(lock) a shared resource.
Only one of Task 1 and Task 2 can only get the lock at any given time.
xSemaphoreTake() always return
pdFALSE which means the semaphore is not available. I’ve checked all my code, no one take the semaphore… This really drives me crazy for days.
I’m not sure why this work nor saying this works for you… Just to share what works for me
It seems that the semaphore is at "taken" status after its creation, by calling
xSemaphoreGive(semaphore); the semaphore now can be used correctly.
Let me know if you know why!
Or maybe one day I will dig into it and update the detail here. 🙂