Hi all,
I'm trying to implement a real time clock using timer a, using an msp430 g2744.
I'm using an external 32.768 kHz oscillator with 12.5pF on each of it's legs.
After I config the clock and the timer,
instead of entering the ISR, the code seems to reset every 1 second (go back to beginning of main function).
I was hoping to get some help on the issue,
Here are my configurations:
void setClk()
{
BCSCTL3 |= LFXT1S_0 + XCAP_0; // 32768-Hz crystal on LFXT1 + Oscillator capacitor selection
DCOCTL = 0; // Select lowest DCOx and MODx settings
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
}
void startRTC()
{
TACCTL0 = CCIE; // TACCR0 interrupt enabled
TACCR0 =32768;
TACTL = TASSEL_1 + MC_1 + TAIE; // ACLK, up mode
g_RTC_Flag = ON;
}
And this is the ISR:
// Timer A0 interrupt service routine
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A(void)
{
//DEBUG_PRINT(("T ISR\n"));
g_RTC_secondsCounter++;
if (g_RTC_secondsCounter % 2)
{
set_LED_OFF(GREEN);
set_LED_ON(RED);
}
else
{
set_LED_OFF(RED);
set_LED_ON(GREEN);
}
}