Api in interrupt CM3

zerbax wrote on Thursday, September 24, 2009:

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

rtel wrote on Thursday, September 24, 2009:

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.

zerbax wrote on Thursday, September 24, 2009:

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

rtel wrote on Thursday, September 24, 2009:

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.

zerbax wrote on Thursday, September 24, 2009:

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

zerbax wrote on Thursday, September 24, 2009:

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

rtel wrote on Thursday, September 24, 2009:

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

zerbax wrote on Thursday, September 24, 2009:

I’m running in real hardware…
Regards

zerbax wrote on Friday, September 25, 2009:

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…