taskYIELD_FROM_ISR
Hi,
I’m wondering if there is anyone that has an implementation of the taskYIELD_FROM_ISR for a SAM7X processor (IAR compiler) that they would be willing to share with me.
Also, what happens if I don’t yield from isr when the message I just sent unblocks a higher priority task then the one currently running? Will the yield take place at the next tick then?
Thanks,
taskYIELD_FROM_ISR
Hi,
I have no implementation of taskYIELD_FROM_ISR for a SAM7X processor, but I’ll give you an idea how you can easily implement it on any ARM processor.
To yield from an ISR is a bit problematic because the ISR should return and leave the stack pointer & C.O. in the same state as before entering the ISR.
taskYIELD_FROM_ISR can be realized by raising a software interrupt in VIC. Choosing this implementation you should carefully use nested interrupts if at all. You can even use the same ISR as for the timer interrupt:
__asm void vPortTimerISR(void)
{
portSAVE_CONTEXT
bl [C-function: if not SOFT interrupt -> call vTaskIncrementTick(), else clear SOFT interrupt]
bl vTaskSwitchContext
portRESTORE_CONTEXT
}
To make the context switch a bit faster you can use separate ISRs:
- timer ISR: performs context switch, increments OS tick, clears timer interrupt
- software ISR: performs context switch, clears software interrupt
I hope it will help you
Regards
Maxim
taskYIELD_FROM_ISR
The macro already exists, its just called something different. See the documentation page for the SAM7S IAR http://www.freertos.org/portsam7iar.html.
portEND_SWITCHING_ISR( ( cContextSwitchRequired ) ), under the interrupt service routine section.
To answer the other question. If you don’t call this then the unblocked task will not run immediately once the interrupt has completed, but will get selected to run the next time the RTOS tick occurs.
Regards.
taskYIELD_FROM_ISR
Thanks!!
taskYIELD_FROM_ISR
I notice that several of RIchard’s excellent examples use task_YIELD_FROM_ISR My appolgies for being so dense but I was unable to find any explanation of the in the manual(s). Given that Richard is so thorough I am assuming I’m looking under the wrong rock :-)
I’m deducing that I need to write an implementation of that macro for any port to a “new” processor – including the ancient AVR mega128. Is that true? And is there some adjacent cast-iron implementation I can model mine upon?
taskYIELD_FROM_ISR
AVR port can just call taskYIELD() in the interrupt. Most ports must not do this. Look at SIG_UART_RECV in DemoAVR_ATMega323_WinAVRserialserial.c for an example.
taskYIELD_FROM_ISR
sotd: thanks mgl