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.

MSP430FR6989: Timer Using DriverLib Module

Part Number: MSP430FR6989


I have implemented a timer that counts down milliseconds using the TimerA module. I used examples in Driverlib as well as ones in the TI Forums as reference.  When I tested it using a stopwatch with the MSP430FR6989 in debug mode, the times seemed accurate. However I realized that I needed a more accurate method of testing the timer. Therefore I tested the timer by counting the number of CPU cycles from CCS during debug mode. However, this showed that the timer was off by a factor of 20 assuming the CPU frequency was 16MHz.

The only way I can see my timer implementation being correct is if the CPU frequency is at 800 kHz, which I am not sure about after reading the MSP430FR6989's datasheet.

Please let me know if I have overlooked or misunderstood something! Code snippet is below. Thank you!

void timer_init()
{
    Timer_A_clearTimerInterrupt(TIMER_A0_BASE);

    // TimerA0 UpMode Configuration Parameter
    Timer_A_initUpModeParam param =
    {
        TIMER_A_CLOCKSOURCE_ACLK,               // ACLK clock source ~32.768kHz
        TIMER_A_CLOCKSOURCE_DIVIDER_1,          // ACLK/?? = ??kHz
        32,                                  // debounce period
        TIMER_A_TAIE_INTERRUPT_DISABLE,         // Disable Timer interrupt
        TIMER_A_CCIE_CCR0_INTERRUPT_ENABLE ,    // Enable CCR0 interrupt
        TIMER_A_DO_CLEAR,                       // Clear value
        true                                    // Start Timer
    };

    Timer_A_initUpMode(TIMER_A0_BASE, &param);
}


void delayMS(unsigned long delayTime){
      millis = 0;
      while (millis < delayTime){}
}


#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=TIMER0_A0_VECTOR
__interrupt
#elif defined(__GNUC__)
__attribute__((interrupt(TIMERA0_VECTOR)))
#endif

void TIMERA0_ISR(void)
{
  millis++;
}

**Attention** This is a public forum