Hello,
I'm using MSP430F2274 and I would like to have a variable that is controlled in timer A0 ISR. The variable should take only three values - 0, 1, and 2 with each interrupt of timer A0. Instead it is getting other values and the program gets stuck. I found this with the debugger but I think this is what happens when the micro-controller runs on its own. Is the low power mode causing this problem? How can I change the code so that the variable doesn't change and the controller still goes to LPM1 between TimerA interrupts. Any advice would be highly appreciated.
This is the code that I think is relevant:
...
volatile int pulse_state = 0;
void main (void)
{
...
}
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A0 (void)
{
switch (pulse_state)
{
case 0:
...
pulse_state = 1;
__bis_SR_register(LPM1_bits + GIE);
break;
case 1:
...
pulse_state = 2;
__bis_SR_register(LPM1_bits + GIE);
break;
case 2:
...
pulse_state = 0;
__bis_SR_register(LPM1_bits + GIE);
break;
}
}