Is use of macro portEND_SWITCHING_ISR() dependent on position within ISR

joehinkle wrote on Monday, May 28, 2018:

I usually use this macro just before exiting the ISR.

I have a situation where portEND_SWITCHING_ISR() needs to be called within a fuction call within the ISR making its position NOT just prior to ISR return but deeper within the ISR stack.

Is using portEND_SWITCHING_ISR() deep within the ISR call stack permissable or do I need to bubble the request up so it used just prior to exiting the ISR?


richard_damon wrote on Monday, May 28, 2018:

It depends on the processor and the port. Some ports the portEND_SWITCHING_ISR() macro sets a pending interrupt which doesn’t actually happen until the ISR ends. In this case it doesn’t actually matter where the call is.

Other ports, (which don’t support nesting interrupts, like the Pic24 port) the portEND_SWITCHING_ISR actually does the yield at that point and the following code in the ISR doesn’t get executed until the task that was interrupted gets run again. In this case it is very important that it be at the end of the ISR.

joehinkle wrote on Monday, May 28, 2018:


I’m using an ARM and saw the IRQ being Set.

Just wanted to make sure something I didn’t know/understand might bite me in the ass.

rtel wrote on Monday, May 28, 2018:

Different ARM processors do this in different ways too. If this is an
ARM Cortex-M then it is fine for the call to portYIELD_FROM_ISR() to
appear anywhere in the ISR (if it were an ARM9, for example, it would
not be ok).