Other Parts Discussed in Thread: MSP430G2553
I have the following written for my MSP430G2553. For some reason, the program never enters the if statement. I have verified that the interrupt is entered and i is incremented, but the program never enters the if statement.
#include <msp430g2553.h>
unsigned int i = 0;
void main(void) {
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR = BIT0 + BIT6; // Set P1.0, P1.6 to output direction
P1OUT &= ~BIT0; // Set the red LED on
P1OUT &= ~BIT6;
TA0CCR0 = 12000; // Count limit (16 bit)
TA0CCTL0 = 0x10; // Enable counter interrupts, bit 4=1
TA0CTL = TASSEL_1 + MC_1; // Timer A 0 with ACLK @ 12KHz, count UP
_BIS_SR(LPM0_bits + GIE); // LPM0 (low power mode) with interrupts enabled
while(1){
if(i > 2)
{
P1OUT ^= BIT6; // Toggle red LED
i=0;
}//end if
}//end for
}//end main
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer0_A0 (void) { // Timer0 A0 interrupt service routine
P1OUT ^= BIT0;
i++;
}