These days we've encountered a problem on timer0 B1 interrupt process. We're using IAR MSP430 7.20.1 as the development environment. And we're using ACLK from VLO 9.4KHz clock as the clock source of timer 0 B1 in LPM3 mode. We uses continuous mode, ID /8, TBSSEL ACLK and TBIE enabled in TB0CTL initialization and TBIDEX /2 in TB0EX0. So the timer B interrupt occurs every 3569.6s, about 59.5minute, we uses the time as about 1 hour. And we need the system keeps in LPM3 sleep mode until about 3 hours arrives and then it's waken up. So we implemented the interrupt as following:
static U_WORD timeoutCounter = 0U;
#pragma vector = TIMER0_B1_VECTOR
static __interrupt void timerBInt( void ) {
switch(TB0IV) {
case TB0IV_TBIFG:
timeoutCounter++;
break;
default:
break;
}
if(timeoutCounter >= 3) {
LPM3_EXIT;
}
}
void ctrlHostSupplyEnterSleepMode( void ) {
...
LPM3;
__no_operation();
drvDioCurMeasSetOn(HIGH);
...
}
But the system doesn't work as we expected. When the timeoutCounter arrives 3 in the 3rd timeout interrupt, it do invoked LMP3_EXIT, but the system is not waken up and break at the breakpoint on drvDioCurMeasSetOn(HIGH) line after LPM3 line in ctrlHostSupplyEnterSleepMode() function in debugger mode(We're sure LPM3 line already invoked and it's in LPM3 mode in the whole test. We tested with dozens of times and added breakpoints in other later lines to avoid there's maybe some code optimization problem to skipped the breakpoint.). So we started to track this issue. After debugging dozens times, we finally found if we remove the if(timeoutCounter >= 3) line and exactly let the interrupt of timerBInt() to invoke LPM3_EXIT before exit. The drvDioCurMeasSetOn(HIGH) line break occurs and the system is waken up. So that mean only the 1st interrupt to invoke LPM3_EXIT will wakeup the system. Code Modified like this:
#pragma vector = TIMER0_B1_VECTOR
static __interrupt void timerBInt( void ) {
switch(TB0IV) {
case TB0IV_TBIFG:
timeoutCounter++;
break;
default:
break;
}
LPM3_EXIT;
}
So we're confused with this because it’s really strange. So now I’d like to inform this issue to your side if anyone of you had met with similar issues like this and give us some suggestions. Thanks!