Cortex A9 Interrupts - vApplicationIRQHandler

wwdjax wrote on Monday, July 01, 2019:

I am writing a function which sets a binary semaphore, calls a hardware interupt, then in the handler must free the semaphore. Correct me if I am wrong but I should re-write vApplicationIRQHandler provided by my port, and documented here. I replaced InterruptHandlerFunctionTable[ ulInterruptID ](); with the function which frees the semaphore. Additionally, I attempt to call __asm volatile ( “SWI 0” ::: “memory” ); to reach the IRQ handler but it is never reached. Can anyone help or provide documentation on the Cortex A9 that better specifies how to call a harware intrupt and then handle it as I cannot seem to find this? Thanks.

rtel wrote on Monday, July 01, 2019:

As I recall…

I replaced InterruptHandlerFunctionTable ulInterruptID ; with the

…these handlers handle IRQ interrupts, whereas this

__asm volatile ( “SWI 0” ::: “memory” ); to reach the IRQ handler but it

generates a supervisor call (SVC as was) interrupt, i.e. not an IRQ
interrupt hence it won’t be handled by InterruptHandlerFunctionTable[].

However according to the link you posted there is already and SVC
handler installed which is called FreeRTOS_SWI_Handler, and looking at
the code for that (which is in
FreeRTOS/Source/portable/GCC/ARM_CA9/portASM.S) it is currently hard
coded as a yield function as it doesn’t check the SVC number, but
instead just assumes SVC is not used for anything other than yielding.
So currently when you call SWI 0 you are just requesting a context
switch, not calling your handler. You can update FreeRTOS_SWI_Handler()
to test the SVC/SWI number, and the call something different depending
on the number.