Hi to all,
I’ve got a problem regarding the use of the xSemaphoreGiveFromISR() function.
I’m using it out of a callback function which is called within an ISR.
I use a binary semaphore as a signal for a completed spi reception.
It has to be taken again immediately after it was given by the callback.
The problem is, that the binary semaphore is still “taken” after calling xSemaphoreGiveFromISR(), so my task blocks again.
Do you have any ideas how to fix my problem?
Here’s the callback function:
static void SPI_Handler_Callback(void)
{
static signed short xHigherPriorityTaskWoken;
The Semaphore is then given again within my callback routine (Interrupt context):
static void SPI_Handler_Callback(void)
{
signed short xHigherPriorityTaskWoken = pdFALSE;
I found out, that if I don’t request a Taskswitch within the Callback, the task comes up again at the next systick, which is after 1ms. But by using portYIELD_FROM_ISR() the task never comes up again. It seems to be a timing problem. If I do it step by step in debugger everything works fine. Maybe there is some kind of race condition (If I wait little, approx. 20µs, after starting the spi-transfere and before trying to take the semaphore, the problem also doesn’t occur?