I’m wondering if there is a special mechanism for handling
interrupts in FreeRTOS? I wanted to write a simple interrupt
routine that would toggle a led when I press a button. But sadly,
when I add the interrupt initialization code, the task won’t start.
Here’s the code:
Try enabling your interrupt only after the freeRTOS scheduler gets started.
In your FreeRTOS port, isn’t there a sample serial driver using interrupts which can help as a reference?
Not familiar with this processor, but the line
AT91C_BASE_AIC->AIC_EOICR = 0xFA;
would be my guess at the error. I presume this is an end of interrupt control, and probably doesn’t want to be conditioned on xHigherPriorityTaskWoken. I would suggest placing it before the if statement.
I got it working. It seems that an interrupt handler that gives a token to a semaphore needs to be called from a wrapper that copies the context. I got it working with:
void vLed_ISR_Wrapper( void )
{
/* Save the context of the interrupted task. */
portSAVE_CONTEXT();
/* Call the handler itself. This must be a separate function as it uses
the stack. */
__asm volatile ("bl vLed_ISR_Handler");
/* Restore the context of the task that is going to
execute next. This might not be the same as the originally
interrupted task.*/
portRESTORE_CONTEXT();
}
Now, correct me if I’m wrong, but that is the only way I managed to get it done. Without the wrapper the processor “hangs” itself. And of course both the wrapper and the handler must be compiled in ARM mode. Or is there a way without using a wrapper?
If your interrupt is wanting to cause a context switch, or wanting to call a FreeRTOS API function, then the wrapper is required - as per the documentation and examples.