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?
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.
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).