/ RTOS

FreeRTOS xSemaphoreTake always fail

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.

Problem

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.

Solution

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. :)

mimimi

mimimi

Currently a Computer Engineering student at the National University of Singapore, passionate about software engineering. Contact me: info at mimimi.fun

Read More
FreeRTOS xSemaphoreTake always fail
Share this