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.

Compiler/MSP430FR5994: Using TimerA

Part Number: MSP430FR5994


Tool/software: TI C/C++ Compiler

I'm trying to test Timer A by using an interrupt to turn a LED on 

It doesn't seem to be working any help would be appreciated

void main(void) {
WDT_A_hold(WDT_A_BASE); // disable watchdog
PM5CTL0 &= ~LOCKLPM5;

P1DIR |= BIT0;

TA0CTL = TASSEL_1 + MC__CONTINUOUS + ID__8;
TA0CTL = TAIE_1;
TA0CTL = TAIFG_0;

_enable_interrupt();

}
#pragma vector = TIMER0_A0_VECTOR
__interrupt void TIMERA_ISR(void) {
P1OUT |= BIT0;
}

  • Hi Steven,

    There are a couple of things you need to do.

    First, in your code you selected TASSEL_1, which is the ACLK. This is fine as along as you assigned a proper clock source to drive the ACLK.
    In my example below I chose the SMCLK to keep it simple.

    Next, because you are looking for the timer overflow, you need to use the TIMER0_A1_VECTOR, not TIMER0_A0_VECTOR, which is assigned to the count/compare CCR0.  Here is a paragraph from the MSP430FR5994 user's guide.



    Next, you should to prevent the code from exiting from main, so a while(1) can be used.

    Last, I toggle my LED in my interrupt handler.

    I tested this on the MSP430FR5994 launchpad.


    int main(void)
    {
    WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer

    PM5CTL0 &= ~LOCKLPM5;

    P1DIR |= BIT0;

    TA0CTL = TASSEL_2 | MC__CONTINUOUS | ID__8;
    TA0CTL &= ~(TAIFG_0); // CLEAR IFG
    TA0CTL |= TAIE_1; // SET IE

    _enable_interrupt();

    while(1); //PREVENT CODE FROM EXITING MAIN

    }


    #pragma vector = TIMER0_A1_VECTOR
    __interrupt void TIMERA_TIMER_OVERFLOW_ISR(void) {
    P1OUT ^= BIT0; // TOGGLE LED
    }

**Attention** This is a public forum