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.

MSP430F2132-ACLK not working

Other Parts Discussed in Thread: MSP430F2132

Hi I am new for MSP430. Now I am working in MSP430F2132, in that I used ACLK as clock source for timers (check the code below) but the counter (TAR) is not incrementing, 

            TA0CCTL0 = CCIE;                                                                          

TA0CCR0 = 1000 - 1;

            TA0CTL = TASSEL_1 + MC_1;

 

Same time if I used SMCLK it is working fine

TA0CCTL0 = CCIE;                                                                          

TA0CCR0 = 1000 - 1;

            TA0CTL = TASSEL_2 + MC_1;

 

In that where I am wrong? Please help me to fix this issue

 

Thank you

  • vasan said:
    In that where I am wrong? Please help me to fix this issue

    Well, if it works with TASSEL_2 but not with TASSEL_1, I'd suspect your ACLK is not running as expected.
    You should look there.
    Since you didn't post your clock setup code (if there is any), I cannot help you further.

  • vasan said:
    Since you didn't post your clock setup code (if there is any), I cannot help you further

    Thank you for your replay.

     

    I have checked with example code msp430x21x2_ta0_04.c (given by TI). This is also not working.

     

    #include "msp430x21x2.h"

     

    void main(void)

    {

      WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

      P1DIR |= 0x01;                                             // P1.0 output

      TACTL = TASSEL_1 + MC_2 + TAIE;            // ACLK, contmode, interrupt

     

      __bis_SR_register(LPM3_bits + GIE);           // Enter LPM3 w/ interrupt

    }

     

    // Timer0_A1 Interrupt Vector (TA0IV) handler

    #pragma vector=TIMER0_A1_VECTOR

    __interrupt void Timer0_A1(void)

    {

      switch (__even_in_range(TAIV, 10))        // Efficient switch-implementation

      {

        case  2:  break;                        // TACCR1 not used

        case  4:  break;                        // TACCR2 not used

        case 10:  P1OUT ^= 0x01;                // overflow

                  break;

      }

    }

    in the same code i have changed TASSEL_1 to TASSEL_2 it is working (with out any other modification).

  • On the 2xxx devices, ACLK is either sourced by LFXT1 or VLO. LFXT1 is the default and there is no automatic fallback.

    So since you do not switch ACLK to VLO in your code, ACLK is source by the EXTERNAL low-frequency watch crystal. If you don't have this crystal Or didn't follow the startup procedute which verifies that this crystal is up and running (which takes several milliseconds), then your ACLK is clocked with 0Hz and so is the timer.

  • If you use ACLK as clock source for Timer A,external watch crystal on XIN XOUT is required.

    Default clock source of MCLK is DCO (about 1.2 Mhz), so your code will working.

    Do you have an external crystal(LFXT1CLK)? If you don't have,you need use DCO as clock source.

  • After I have changed the clock source from LFXT1CLK to VLO using BCSCTL3 |= LFXT1S_2; timer is running now, but when I started the timer it is not running immediately it is taking some millisecond even I have switched the clock source well before?

  • How do you know that the timer is not starting from some milliseconds?

    The tiemr is sourced by VLO, which is, in best case, 20kHz. This means the first timer interrupt, which happens on timer tick 1000 (with the code you originally posted), will happen after 50ms or longer (depending on the actual VLO speed on your MSP). That's correct with this code.
    If you do a TAR=998 right after setting the TACCR0 value, it will happen almost immediately, as this will bias the TAR register towards the CCR0 value, so the interrupt comes almost instantly (well, 1 or 2 ticks with a 20kHz clock is still an eternity, yet a short one)

**Attention** This is a public forum