As the title says, when i notify a task from the ISR call, i get an exception on the portEXIT_SWITCHING_ISR() call.
If i comment out the notification it runs fine.
Here’s the code for the creation of the task to be notified:
#pragma shadow_registers = full // Naked.
static void myInt( void )
{
portENTER_SWITCHING_ISR(); /* This ISR can cause a context switch, so the first statement must be a call to the portENTER_SWITCHING_ISR() macro. This must be BEFORE any variable declarations. */
BaseType_t pxHigherPriorityTaskWoken = 0;
xTaskNotifyFromISR(testTaskHandle, // notify
1,
eSetValueWithoutOverwrite, // without overwrite, we can check if task was already busy - this should not happen
&pxHigherPriorityTaskWoken); // in case of success, this should always be set to true, resulting in a context switch
// pxHigherPriorityTaskWoken <-- PLACE THIS IN R12!
portEXIT_SWITCHING_ISR(); /* Exit the ISR. If a task was woken then a context switch will occur. */
}
The AVR32 port in the FreeRTOS download was designed for ES chips, so please use the port provided by Atmel (now Microchip) themselves.
Besides that, just looking at the example we provide, I see that the interrupt handler has to be a naked function that just calls a non-naked C function between the entry and exit macros, as per:
/*
* USART interrupt service routine.
*/
#if __GNUC__
__attribute__((__naked__))
#elif __ICCAVR32__
#pragma shadow_registers = full // Naked.
#endif
static void vUSART_ISR( void )
{
/* This ISR can cause a context switch, so the first statement must be a
call to the portENTER_SWITCHING_ISR() macro. This must be BEFORE any
variable declarations. */
portENTER_SWITCHING_ISR();
prvUSART_ISR_NonNakedBehaviour();
/* Exit the ISR. If a task was woken by either a character being received
or transmitted then a context switch will occur. */
portEXIT_SWITCHING_ISR();
}
(cut from our demo code).
The comment in your code implies the shadow_registers pragma is doing the same thing - but try using the naked attribute instead just in case.
Does the pragma set up a stack frame? If so, then it is not a naked function. If not, then you can’t define a variable on the stack as you are (the pxHigherPriorityTaskWoken variable) - that would have to be done inside the non-naked C function called from the naked function.