This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

msp430 timer used as rtc misbehaves

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);
  }
}

  • Omri,

    The issue is that you've set the TAIE bit in TACTL.  This is enabling a different interrupt that is not serviced by the TACCR0 vector that you are using.  TAIFG is serviced by the next vector down the list (0xFFF0h).  

    What is happening is that the TimerA counter is overflowing and setting TAIFG.  Your code tries to go into the TAIFG ISR but you haven't defined an interrupt handler for that vector.

    Don't set TAIE or define an interrupt handler for the TAIV vector and the resets should go away.

**Attention** This is a public forum