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.

need a help for MSP430x26 clock

Other Parts Discussed in Thread: MSP430FG4618

Hello,

I am playing with MSP430x26 MCu, currently i am trying to figure out the Basic timer + Timer_A. I am working on T.I code for the same family http://www.ti.com/lit/zip/slac151b. I have very basic and simple question and to find out the answer, i have read all the post regarding DCO, ACLk and MCLK but didnt get any clear idea. I need your suggestion on the step i have taken to set different registers, for example in all example code for timer or basic timer, the values for basic timer (DCO, MCLK, SMCLK and ACLK) are always assumed. For e.g in some files the DCO is default 1.45 MHz and there is no setting provided in main file and the register settings DCOCTL and BCSCTL1 are always set for maximum fdco(15,3). Same is the case for ACLK. I have tried to work out with to set DCO by  

void main(void)
{
 
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  //DCO =1.45 MHz
  BCSCTL1 |= RSEL0 +RSEL1 +RSEL2; (Rsel=7)
  DCOCTL  |= DCO0+DCO1;               (DCO 3)

}

For ACLK i am working on an example code MSP430x261x_ta_05 where the led is toggeled on ACLK overflow and ACLK is source from TACLK or external crystal on xin and x out pin, the orginal code was as following, where i have palced breakpoint on interrupt module and the breakpoint was never execute.  As i dont hav any external crystal.

void main(void)
{
  WDTCTL = WDTPW + WDTHOLD;             // Stop WDT
   P4DIR |= 0x08;                        // P1.0 output
  CCTL0 = CCIE;                         // CCR0 interrupt enabled
  CCR0 = 1000-1;
  TACTL = TASSEL_1 + MC_1;              // ACLK, upmode

  _BIS_SR(LPM3_bits + GIE);             // Enter LPM3 w/ interrupt
}

// Timer A0 interrupt service routine
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
  P4OUT ^= 0x08;                        // Toggle P1.0
}

While reading the data sheet on page 289 its written

"ACLK is sourced from LFXT1CLK in LF mode with an internal load capacitance of 6pF".

By following this i did a modification in code file

oid main(void)
{
  WDTCTL = WDTPW + WDTHOLD;             // Stop WDT
  //Enable a ACLK
  BCSCTL1 |=XTS;                          
  BCSCTL3 =  LFXT1S0 + XCAP_1 ;
  P4DIR |= 0x08;                        // P1.0 output
  CCTL0 = CCIE;                         // CCR0 interrupt enabled
  CCR0 = 1000-1;
  TACTL = TASSEL_1 + MC_1;              // ACLK, upmode

  _BIS_SR(LPM3_bits + GIE);             // Enter LPM3 w/ interrupt
}

// Timer A0 interrupt service routine
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
  P4OUT ^= 0x08;                        // Toggle P1.0
}

Now i can see the breakpoint working, but i cant see my LED toggle. Kindly guide me what else i am missing?

BR

 

  • You mentioned that you do not have an external crystal.  Do you have an external clock driving the XIN pin?
    If not, then your only option for ACLK is to drive it from the internal LP/LF oscillator (VLOCLK).  Please reference Figure 5-1 of the MSP430x2xx Family User's Guide (SLAU144) in the Basic Clock Module+ section.
    If there is not a clock on XIN, the mux needs to be configured such that VLOCLK is propagated to ACLK.  This is performed by configuring LFXT1Sx=10.  This bit field is found in the BCSCTL3 register.

    I have provided an updated MSP430_261x_ta_05.c file below.  I have only added a line (in bold) to configure the above bit field.

    #include  <msp430x26x.h>

    void main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;             // Stop WDT
      BCSCTL3 |= LFXT1S_2 ;
      P1DIR |= 0x01;                        // P1.0 output
      CCTL0 = CCIE;                         // CCR0 interrupt enabled
      CCR0 = 1000-1;
      TACTL = TASSEL_1 + MC_1;              // ACLK, upmode

      _BIS_SR(LPM3_bits + GIE);             // Enter LPM3 w/ interrupt
    }

    // Timer A0 interrupt service routine
    #pragma vector=TIMERA0_VECTOR
    __interrupt void Timer_A (void)
    {
      P1OUT ^= 0x01;                        // Toggle P1.0
    }

  • Hello BrandonAzbell,

    Thank you for replying, i have checked my board schematic and i have a high freq (16 MHz) crystal there, sorry for my reply that i dont have a crystal on Xin as i am also using MSP430FG4618 exp boards, where there is nothing on XIN. I have tried to run your code, and it worked for led toggling after 1 second in up mode. Now i am trying to figure out how to drive my clock from High frequency (HF) mode for LFXT1CLK.

    One more thing from your reply, you wrote "If there is not a clock on XIN, the mux needs to be configured such that VLOCLK is propagated to ACLK". Do you want to point that i have to multiply VLOCLK (12 KHz) to reach ACLK (32 KHz)?

    Thanx once again for your time and guidance.


       BR

  • RFeng said:

    Thank you for replying, i have checked my board schematic and i have a high freq (16 MHz) crystal there, sorry for my reply that i dont have a crystal on Xin as i am also using MSP430FG4618 exp boards, where there is nothing on XIN. I have tried to run your code, and it worked for led toggling after 1 second in up mode. Now i am trying to figure out how to drive my clock from High frequency (HF) mode for LFXT1CLK.

    Are you able to drive ACLK from your 16MHz crystal on XIN/XOUT?  Try the following:

    LFXT1Sx = 10
    XTS = 1
    XCAPx = 00

    RFeng said:

    One more thing from your reply, you wrote "If there is not a clock on XIN, the mux needs to be configured such that VLOCLK is propagated to ACLK". Do you want to point that i have to multiply VLOCLK (12 KHz) to reach ACLK (32 KHz)?

    The point that I was attempting to make is based on Figure 5-1 of the MSP430x2xx Family User's Guide (SLAU144) on page 5-3.  ACLK is sourced by 1 of 2 possible clock sources, 1) LFXT1CLK and 2) VLOCLK.  Therefore, if the mux is selected to propagate LFXT1CLK to ACLK and there isn't anything driving LFXT1CLK, then ACLK will not be toggling.

     

  • Hello BrandonAzbell,

    I have tried to run LFXTCLK in HF mode (16 MHz), by applying your advised settings.

     BCSCTL1 |= XTS ;
      BCSCTL3  |= LFXT1S_2 + XCAP_0;

    with a toggle rate in upmode (50 Hz), but then there is no response. Then i divide the ACLK by 8 and now the LED starts toggling but with very fast interval.

    BCSCTL1 |= XTS+DIVA_3 

     I am working on how to increase my toggle rate, as i want a timer interrupt on different time e.g 1 sec, 2 sec and 0.5 ms.

     

    Best Regards

     

     

     

  • RFeng said:

    with a toggle rate in upmode (50 Hz), but then there is no response. Then i divide the ACLK by 8 and now the LED starts toggling but with very fast interval.

    BCSCTL1 |= XTS+DIVA_3

    What was the value you put into the timer compare register?  The register settings I provided before we to assist in propagating your high frequency clock (ie. 16MHz) to the Timer A.  It appears that you are now achieving this result, but you indicate the toggling of the timer is very fast.
    What signal are you driving to an LED?  Is this the timer output directly?

    RFeng said:

    I am working on how to increase my toggle rate, as i want a timer interrupt on different time e.g 1 sec, 2 sec and 0.5 ms.

    As you have discovered, your base frequencing for the Timer A is now ACLK, which without any dividing using the DIVAx field, the ACLK frequency would be 16MHz.  Setting DIVAx=3 makes the TimerA input clock = ACLK/8 or 2MHz.

    If you desire a 1 sec, 2 sec or 0.5 ms period from the Timer, then you will need to put an appropriate value in the TACCRx register when running the TimerA in compare mode.
    (Do you really mean 0.5 millisecond, or 0.5 seconds?)

    With that fast of a reference clock to the Timer A (ie. 2MHz input clock), there is no way you are going to get the Timer A to generate an interrupt every 1 sec, 2 sec, etc.  It is going way too fast.  The Timer A only has a 16-bit compare register, which is 65536.  Also, it has a pre-divider of up to /8.
    Therefore, the slowest interrupt interval, or period, possible with this configuration is 2MHz /(8*65536) or 3.8Hz which is 262 msec.

    To achieve your worst case period, ie. interrupts every 2 secs, you need to have a <= 1.048MHz input clock.

    However, if you do configure ACLK to be sourced from VLOCLK, the 12KHz frequency, then you should be able achieve generating interrupts every 1 sec, 2 sec or 0.5 sec.

  • Hello,

    The value i have used in CCRO is 50000 less than 0xffff. In case of ACLK=16MHz it was 16MHz/50000  . Then i divide ACLK by DIVA_3 (8), so 16 MHz/(8*50000) = 5 Hz. 

    What signal are you driving to an LED?  Is this the timer output directly?

    Yes, it is a simple timer output, where timer A is running in upmode and LED toggle at every interval (CCRO).

    P1DIR |= 0x08;                        // P1.0 output
    CCTL0 = CCIE;                         // CCR0 interrupt enabled
    CCR0 = 50000;
    TACTL = TASSEL_1 + MC_1

    I have tried with ACLK @12 Khz with 1 second interval and yes it did work, by setting CCRO = 12000. I can see my LED toggle after every 1 second, so no problem with that as currently i am playing around with these registers.

    For my application i need a accurate crytsal and i guess i have to add 32KHz on my board.

     Thank you once again for your time and response. I have few more questions regarding MSP430FG4618 exp boards, as i also had some problem there too. But first i ll try your given advices there and lets see whats the output.

    Best Regards

**Attention** This is a public forum