Other Parts Discussed in Thread: ENERGIA, MSP430F2013
Hi all,
I've been looking around and I haven't been able to find any good help on exiting low power mode, in particular in use with Timer_A. The following is my C code to turn on the LED for a split second, by implementing a delay in between turning the LED on and off:
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= 0x01; // P1.0 output
P1OUT |= 0x01; // LED ON
delay_us(65535); // DELAY
P1OUT ^= 0x01; // LED OFF
}
void delay_us(unsigned int us) {
TACCTL0 = CCIE;
TACCR0 = us;
TACTL = TASSEL_2 + MC_1; // UP MODE
_bis_SR_register(LPM0_bits);
}
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
_bis_SR_register_on_exit(LPM0_bits);
}
Note that LMP0_bits is defined as CPUOFF. Most of this code came from TI's example projects page (msp430x20x3_ta_02, Timer_A, Toggle P1.0, CCR0 Up Mode ISR, DCO SMCLK).
With this code above, the LED simply stays turned on forever. Could anyone tell me if I am entering and exiting low-power mode correctly?
Thanks,
Matt