Yielding from an ISR

How important is it that vPortYieldFromISR() is called at the very end of the ISR handler?  For example: void UART0_IRQHandler(void)
{
   Bool woken = false;
  
   someAPICall(&woken);    portyieldfromisr(woken); } is this functionally different from: void UART0_IRQHandler(void)
{
   doStuff();
} void doStuff()
{
   Bool woken = false;     someAPICall(&woken);     portyieldfromisr(woken);
} For refernce im using Rowley Crossworks and the LPC1763.

Yielding from an ISR

On some ports it is extremely important, essential even, that the yielding is done as the last thing.  On the Cortex-M however, it is not important, and either of your code snippets are fine, provided your doStuff() function is only called from an interrupt.  If it is not called from an interrupt then it will still be ok provided the function that calls it takes care of the yielding if one is required. Regards.

Yielding from an ISR

Hi Richard, Could you please explain why the yield not is important on the Cortex-M? Best regards, Frank Andersen

Yielding from an ISR

Every port is different.  Some require direct manipulation of the ISR exit code, in which case the yield must be at the end, or use function calls, which again means it has to be at the end, but the Cortex-M just pends the PendSV interrupt, and that can be done at any time because the interrupt won’t execute until the original ISR exits (because the PendSV is the lowest priority).