I am observing an issue with nested interrupts. I know I should avoid using nested interrupts but believe me, in this case there was no other choice.
This is the scenario:
- MSP is in Low Power Mode 3 (LPM3).
- RTC interrupt occurs.
- Inside the RTC's ISR, I set GIE to enable nesting.
- TA0 (or others) interrupts before returning from RTC's ISR (nesting).
- Inside the TA0 I change the Status Register (SR) bits to exit LPM (using __bic_SR_register_on_exit).
- The MSP does not respond anymore.
Note: If I don't try exiting LPM from the nested interrupt, the MSP behaves as expected.
In the following thread, Jens-Michael Gross, mentioned that "the nested interrupt cannot exit LPM".
https://e2e.ti.com/support/microcontrollers/msp430/f/166/t/349661?Nested-interrupts-and-jump-table
I understand the SR and PC are saved in the stack twice. Then, at the end of the nested interrupt ISR, the latest SR saved in the stack is modified (to exit LPM) and retrieved, then the PC will retrieved an instruction from the RTC's ISR and will continue executing the RTC's ISR. Then, at the end of the RTC's ISR, the SR will be retrieved again form the stack with the values saved before entering the RTC's ISR. For that reason, the MSP will not go out form LPM in that moment.
But, what I don't understand is why the MSP doesn't wake up at all, later when another interrupt occurs and there is no nesting enabled.
I would really appreciate any inputs on this matter.
Thanks in advance.