Hi,
I'm using msp430g2231 launchpad. I'm trying to blink the LED whenever the TimerA's TACCR0 overflows and sets the CCIFG flag. I'm using ACLK=12Khz clock. CCR0=24,000. This will give me 2s LED blinking rate. Here is the code.
Problem: I'm not getting 2 second blinking rate.
Code:
#include <msp430g2231.h>
/*
* main.c
*/
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P1DIR |= BIT6; // set P1.6 as output
P1OUT &= ~BIT6;// each time clear the P1.6
TACTL= TASSEL_1 + MC_2; // ACLK=12KHz
CCR0 = 24000; //TACCR0 counts to 12000
// 12000 Hz / 24000 = 0.5Hz = 2s
while(1)
{
if ((TACCTL0 & CCIFG) == 1) // is there any other way to check the flag?
P1OUT ^= BIT6;
TACCTL0 &= ~CCIFG; // is this correct way to reset the flag?
}
}
Thanks
for code insertion for better look and readability.