Api in interrupt CM3

I’ve a problem with FreeRtos, i’m programming on CORTEX M3.
My application is very easy, there is a task that waits on semaphore
and toggle a led, the semaphore is give by a ISR: void EXTI9_5_IRQHandler(void)
{      portBASE_TYPE xHigherPriorityTaskWoken= pdFALSE;      xSemaphoreGiveFromISR(xSem, &xHigherPriorityTaskWoken);         if(xHigherPriorityTaskWoken==pdTRUE)
                        portYIELD();
} The problem is that when the API "xSemaphoreGiveFromISR" is called ,
the programm crashes.
If i don’t use API the programm runs…
Can someone help me?
thanks

Api in interrupt CM3

Can you check that the semaphore xSem was created correctly and is not NULL. Also, can you step into the xSemaphoreGiveFromISR() function to see at what point the crash occurs. Regards.

Api in interrupt CM3

The semaphore is created correctly.
I see, that xSemaphoreGiveFromISR() runs correctly, the program crashes on portYIELD(), infact doesn’t force context switch…

Api in interrupt CM3

portYIELD() should not cause a context switch directly – the switch is just pended.  Try placing a break point on the function called xPortPendSVHandler() in port.c. Regards.

Api in interrupt CM3

i can’t place a break point, because i don’t simulate the program…

Api in interrupt CM3

But i place on the function xPortPendSVHandler() a led that have to toggle, but doesn’t toggle..

Api in interrupt CM3

<code> i can’t place a break point, because i don’t simulate the program…</code> I don’t understand that – are you running in a simulator or on real hardware? <code>But i place on the function xPortPendSVHandler() a led that have to toggle, but doesn’t toggle..</code> xPortPendSVHandler() is a naked function written in assembly – you cannot add code to it unless it too is assembly code. Regards.

Api in interrupt CM3

I’m running in real hardware..
Regards

Api in interrupt CM3

I’ve tried to take off the function portYIELD, and program runs…
but now the time between the ISR and handler task is not deterministic..