masoandro wrote on Tuesday, June 05, 2018:
Hello!
First time poster, long time lurker.
I’m getting a bit lost trying to track down a callback issue I am having. Basically, after a short time (not right away), I get stuck inside the callback and it loops indefinitely through the callback function. I’m using RTOS 7.3.0 on an ARM processor.
I am using a timer to switch between a task, much like in this example.
I create the timer using xTimerCreate and the callback function is called successfully after taking the semaphore in the parent function. Inside the callback function, I am also calling other functions that take semaphores. The way I understand it, taking an additional semaphore, even in the callback, should allow a queue of the taken processes to form. This is because I have multiple functions communicating over the same bus - they have to wait their turn.
When, during the callback, the function is called, there is a xSemaphoreTake() followed by instructions, and then xSemaphoreGive(). It then returns to the callback function and - shoud - return to the parent function after I call xTimerStopFromISR(xTimer, &xHigherPriorityTaskWoken) and xSemaphoreGiveFromISR(parentSemaphore, &HigherPriorityTaskWoken).
One of my guesses is that, somewhere along the line, the semaphore address is being written over. But I don’t see a change in the semaphore that would indicate this behavior.
My other guess is that there is some kind of race condition where the routine I am calling from within my callback is trying to take a semaphore while a same priority semaphore is being taken elsewhere (all of my semaphores/tasks have the same priority).
Can anyone speak to this issue as to why the callback loops without ever returning back to its parent function?
Thank you!