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.

MSP430FR2676: Timer A change clock dividers

Part Number: MSP430FR2676

Hello,

i have a problem with my MSP430FR2676 Timer A clock dividers.

If i change the clock divider from ID__1 to ID__8 (after set TACLR) then it will also be slower.

But if i want to change the clock divider from ID__8 to ID__1 then it remains slow?

Thank you for your help.

#################### CODE ####################

while(1)

   {    

        TA0CTL |= MC__STOP;
        TA0CTL |= TACLR;
        TA0CCTL0 = CCIE;                        
        TA0CCR0 = 5000;
        TA0CTL  = ID__1;
        TA0CTL |= TASSEL__SMCLK | MC__UP;
        __delay_cycles(3000000);

        TA0CTL |= MC__STOP;
        TA0CTL |= TACLR;
        TA0CTL  = ID__8;
        TA0CCTL0 = CCIE;                         
        TA0CCR0 = 5000;
        TA0CTL = TASSEL__SMCLK | MC__UP;         
        __delay_cycles(3000000);

    }

  • I tried to understand your code. You are setting Timer A to create interrupts when it hits 5000 value in TA0R but you are not handling those interrupts. delay_cycle function has nothing to do with Timer interrupts. They are busy waiting functions that are sourced from MCU active operation. Since you are not changing MCLK, __delay_cycles(3000000); function will wait the same amount of time.

    Please check the example on timer interrupts below:

    dev.ti.com/.../nodeContent

  • TA0CTL |= MC__STOP;

    This doesn't stop the timer, since MC__STOP==0. Try instead:

    > TA0CTL = (TA0CTL & ~MC_3);   // MC=0

    Your second example doesn't actually run the timer with ID__8, since the last line sets ID=0 (ID__1). I'm guessing the code that produced your symptom used something like:

    > TA0CTL |= ID__1;  // Change ID__8 to ID__1

    which (similar to the MC example) doesn't set ID=0 since ID__1==0. In this case you would

    > TA0CTL = (TA0CTL & ~ID_3);

    ------------------------

    Unsolicited: Trying to set TA0CTL piecemeal is rarely needed and it's easy to make mistakes. I suggest setting everything at once:

    > TA0CTL = TASSEL__SMCLK | MC__UP | ID__8 | TACLR;

    after everything else is set. Yes, it's a style thing, but it helps keep me out of trouble.

  • Thank you very much for your help!

    This solved my problem. I have made several mistakes.

**Attention** This is a public forum