taskYIELD from non-ISR routine on an MSP430

nobody wrote on Wednesday, May 03, 2006:

Dear dispensers of wisdom,

The implementation of taskYIELD for the MSP430 GCC port calls vPortYield. 
To make the stack look like the task was pre-empted by an ISR, vPortYield does the following:

asm volatile ("push r2");  // Save status register
_DINT(); // Disable interrupt.
portSAVE_CONTEXT();  // Save the context etc.

However, since taskYIELD is not called from an ISR, the Program Counter is not saved (register r0).

So if this context is restored, how could the task resume from the yield point.

Thanks
RJ

nobody wrote on Wednesday, May 03, 2006:

I guess it would be saved automatically as the function call return.  The saving of r2 is probably the only difference between the function call stack frame and an interrupt stack frame.