I’m just looking at this now:
It turns out that vTaskSwitchContext() will corrupt the stack if it is not surrounded by a SAVE_CONTEXT/RESTORE_CONTEXT pair.
According to the documentation page for the port, if portYIELD_FROM_ISR() is to be used, then the ISR
must have an assembly file wrapper that calls SAVE_CONTEXT/RESTORE_CONTEXT. So far, from looking at this, I agree that attempting to call portYIELD_FROM_ISR() without the wrapper will corrupt the stack which is why it is not valid to do that.
#define portYIELD_FROM_ISR( xHigherPriorityTaskWoken ) if (xHigherPriorityTaskWoken) vPortYield()
That will cause a BRK instruction to be executed inside your ISR. I’m not sure if that is dangerous, but I would definitely say it is undesirable for reasons of efficiency.
Please let me know if you are seeing an issue when portYIELD_FROM_ISR() is used as intended, and, if so, provide a test case to replicate the issue so I can investigate further.
Regards.