Hi!
I am porting a RTOS fo the MSP4305529 platform.
I am having an issue regarding the GIE bit while wainting the system tick, whitin the schedule funciont of the OS.
In C, is something like this:
BackUp_and_DisableGIE;
/* lot of code */
while( !NewReadyTask() )
{
RestoreGIE;
Pause(); //here will be executed the LPM entering macro, or something similar. Now, there is NOP.
BackUp_and_DisableGIE;
}
ContextSwitch();
RestoreGIE;
The idea is to loop until the tick puts some task in running estate, and then when it happens, the Context Switch is done, and the execution continues.
The system hangs during the while loop. Somehow, the GIE bit is being disabled.
When the pause function is a LPM, surely I will eneble the GIE within the ISR vector, but for now is just a nop.
THe RestoreGIE and BackUp_and_DisableGIE are macros, where I tried fo follow every rule from the errata sheet, and the family guide in regard to the pipeline, the eint an dint instructions.
#define BackUp_and_DisableGIE() SR_BACK___ = _get_SR_register(); \
_disable_interrupts() ; \
__asm__ __volatile__ ("nop");
#define RestoreGIE() if( SR_BACK___ & GIE ) \
{ \
__asm__ __volatile__ ("nop"); \
_enable_interrupts() ; \
}
Maybe you can help me some how.
Thanks in advance.
UPDATE:
- I am using gcc (SOMNIUM Technologies Limited - msp430-gcc 5.3.0.219) 5.3.0
- I am not using optimizations
- I have only 1 Enabled IRQ, that is the one for the tick. I placed a counter in the tick irq handler, in order to see if is a consistent behavior or something else. The counter changed during different runs... when the while is stucked.
- I am debuging with eclipse + mspdebug.
- I added a little delay after Pause() (with an ugly for(;;) ), and started to work... It doesn't hangs there