In this project i'm using a MSP430F169. The basic idea is main goes into LPM3 waiting for a timer to trigger the ADC interrupt. At the end of the ADC interrupt main gets woken up using _BIC_SR_IRQ(LPM3_bits); What will happen if main executes for too long and the ADC interrupt completes again while the processor is still awake?
void main(void) {
...
while(1) {
// Put main to sleep with interrupts enabled until ADC tells us to wake up
_BIS_SR(LPM3_bits+GIE);
...
}
}
Here's the bottom of the ADC interrupt in disassembly:
_BIC_SR_IRQ(LPM3_bits);
001D3A C0B1 00D0 0014 bic.w #0xD0,0x14(SP)
001D40 3C3A jmp 0x1DB6
To me it seems like bic.w will put the processor back in LPM3 if it is already awake. I'm also not sure why the bic.w has the SP as destination instead of the SR.