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.

CCS/MSP430FR2476: Bug in code to init counter A

Part Number: MSP430FR2476

Tool/software: Code Composer Studio

When I try to set TimerA to UP mode, it sets it to UP/DOWN.  MC_UP is defined as the constant 0x0010 but it ORs in 0x0030. This can be seen by single stepping this code:

//****************************************************************************
//              Initialize TimerA
//****************************************************************************
void initTimer_A(void)
{
    //  Timer0_A is configured for continuous mode, count up.
    //  Overflows and interrupts when reaches CCR0.
    //  CCR0 = 8000 for 8 MHz SMCLK to give 1 ms interrupts.

    TA0CCTL0 |= CCIE;                             // TACCR0 interrupt enabled
    TA0CCR0 = INTERRUPT_COUNT_MAX;                // Divide 8 MHz by 8000
    TA0CTL = 0;
    TA0CTL |= TASSEL__SMCLK | MC__CONTINUOUS;     // SMCLK, continuous mode
    TA0CTL |=  MC__UP;                            // Compiler bug really sets it to up/down
    TA0CTL = 0x211;                               // Correct it from 0x231 to 0x211
    __bis_SR_register(LPM0_bits | GIE);           // Enter LPM0 w/ interrupts

}

  • >    TA0CTL |= TASSEL__SMCLK | MC__CONTINUOUS;     // SMCLK, continuous mode
    >    TA0CTL |=  MC__UP;                            // Compiler bug really sets it to up/down

    This code sets the MC field to 0x020|0x010 (Continuous|Up), which is 0x030==Up/Down.

    The way it reads, I suspect the first line was intended to be:

    >  TA0CTL |= TASSEL__SMCLK ;     // SMCLK, leave MC=0 (stopped)
       

**Attention** This is a public forum