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.

MSP430F2418 VLO calibration

Other Parts Discussed in Thread: MSP430F2418

How is the very low power low frequency oscillator (VLO) calibrated for the MSP430F2418?

Customer used the value line (G series) before and was able to calibrate the VLO with help of the available appnotes. It seems to be different for the MSP430F2418. 

Any ideas?

  • Guido van Veldhuizen said:

    How is the very low power low frequency oscillator (VLO) calibrated for the MSP430F2418?

    Customer used the value line (G series) before and was able to calibrate the VLO with help of the available appnotes. It seems to be different for the MSP430F2418. 

    Any ideas?

     
    Please have your customer report how they do with this application note applicable to the 2xx devices (which includes the MSP430F2418).
  • Guido van Veldhuizen said:
    How is the very low power low frequency oscillator (VLO) calibrated

    Not at all. it's a free-runnign oscillator designed for low power, not for any accuracy. It just provides some clock signal if any othe rclock source is off. No warranty for its exact frequency. Variation is large and stability over temperature and VCC is poor. But better to have a clock of some sort than having none at all.

  • Guido,

    Jens-Michael is correect, there is not a native way of calibrating the VLO using register settings or using Tag-Length-Value (TLV) calibration constants as for the DCO.

    Jason is correct in that the VLO Library is a way of creating more accurate interval measurement for capture/compares using the DCO and a Timer.

    Also the range for the VLO specifically for the MSP430F2418 is 4kHz-20kHz with a typical output frequency of 12kHz at 2.2 or 3V Vcc.

    This is noted on page 48 of the MSP430F2418 Datasheet.

    MSP430F2418 Datasheet: http://www.ti.com/lit/ds/symlink/msp430f2418.pdf#page=48

    For a more accurate low frequency clock source I recommend using a 32kHz external crystal using the LFXT1.

  • Thank you all for your responses. I received an email from my customer:

    It is working now. To get it to work on the  MSP430F2418 he had to comment out the line:

     

      -   bic.b   #0xC0,        &P2SEL    ; clear P2SEL bits to avoid XTAL interference.

     

    Thanks again for the help.

  • Guido,
     
    This sounds like rather than wanting to calibrate the VLO, the customer wanted to configure ACLK to source the VLO and know how to prevent the LFXT1 from interfering with the input line to ACLK.
     
    It should also be noted if this is the case that the OSCOFF bit within the SR register, to IIurn off the LFXT1 oscillator.
     
    BIS.W #OSCOFF,SR ; Turn off osc.
     
    Also setting the OSCOFF bit during LPM4 disables the VLO, as well as ACLK as clock source.
     
    The setting of the OSCOFF bit within the Status Register (SR) is the difference between entering LPM3 to LPM4.
     
    Proper initialization of the VLO along with the setup for using the calibration of the VLO as noted in the app note that Jason referenced in the forum thread are included in the attached code example.
     
    MSP430x261x_vlo_capture.c:
    //******************************************************************************
    //  MSP430x26x Demo - Basic Clock, VLO-Driven Timer with VLO Compensation
    //
    //  This example toggles P1.0 approx. every second, using a timer driven by the
    //  VLO.  The VLO freq can vary between 4kHz-20kHz, so the timer compare value 
    //  must be adjusted to compensate, in order to produce a one-second interval.  
    //  So in effect, this code performs a kind of "calibration" of the VLO.  This 
    //  is done by counting the number of 1MHz DCO pulses in one ACLK=VLO/8 period, 
    //  assigned to dco_delta.  VLO is /8 in order to increase the number of DCO 
    //  pulses in one ACLK pulse, increasing the resolution of the measurement, 
    //  and therefore the accuracy of the one-second interval.  Since 1,000,000 
    //  DCO pulses at 1MHz are required to produce a one-second interval, the 
    //  number of VLO/8 pulses in one second is given by 1M/dco_delta.  This value 
    //  is loaded into TACCR0 as the timer compare value.  
     
    //  MSP430x2xx devices are shipped with calibration values in info memory that,
    //  when used by software, allow the DCO to operate within approx. +/-1% of 
    //  common values such as 1MHz.  (See the datasheet for add'l information.)  
    //  Through the algorithm shown here, this accuracy is extended to the VLO.  An
    //  additional source of error in this algorithm is that the VLO/8 freq will 
    //  most likely not be evenly divisible by the DCO freq, and therefore up to 
    //  one DCO pulse may be lost.  At nominal values, there are 400 1MHz DCO 
    //  pulses in one 2.5kHz VLO/8 pulse, so losing one clock pulse produces 
    //  ~0.25% error, in addition to the error tolerance of the calibrated DCO.  
    //  ACLK = VLO/8, MCLK = SMCLK = 1MHz
    //
    //                MSP430F261x/241x
    //             -----------------
    //         /|\|              XIN|-
    //          | |                 |
    //          --|RST          XOUT|-
    //            |                 |
    //            |                 | 
    //            |        P1.0/ACLK|-->LED 1 second interrupt
    //
    //  
    //  B. Nisarga
    //  Texas Instruments Inc.
    //  September 2007
    //  Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.42A
    //******************************************************************************
    #include <msp430x26x.h> 
    
    unsigned int dco_delta;
    
    // Function Prototype
    unsigned int  measureVLO( void );
    
    void main(void)
    {
      WDTCTL = WDTPW +WDTHOLD;                  // Stop Watchdog Timer
      P1DIR |= 0x01;                            // P1.0 output
     
      dco_delta = measureVLO();                 // dco delta = number of
                                                // 1MHz cycles in 8 VLO cycles
      //Clock settings: DCO freq = 1MHz; ACLK = VLO/8
      
      // Timer A interval interrupt setup
      TACCTL0 = CCIE;                           // TACCR0 interrupt enabled
      TACCR0 = (1000000 / dco_delta);             
      TACTL = TASSEL_1 + MC_1;                  // ACLK, upmode
      P1OUT = 0x01;
      
      _BIS_SR(LPM3_bits + GIE);                 // Enter LPM3 w/ interrupt
    
    }
    
    // Timer_A0 Interrupt Vector 
    #pragma vector=TIMERA0_VECTOR
    __interrupt void Timer_A0(void)
    {
      P1OUT ^= 0x01;                            // Toggle P1.0
    }
    
    // This function measures the number of 1MHz clock pulses in 8 VLO cycles
    unsigned int  measureVLO( void )
    {
      static unsigned int start_count, stop_count;
      // Clock settings to achieve the good resolution for VLO freq measurement
      BCSCTL1 = CALBC1_1MHZ;                    // Set range
      DCOCTL = CALDCO_1MHZ;                     // Set DCO step + modulation
      TACCTL2 = CM_1+CCIS_1+CAP;                // CAP, ACLK
      TACTL = TASSEL_2+MC_2+TACLR;              // SMCLK, cont-mode, clear
      BCSCTL3 |= LFXT1S_2;                      // ACLK = VLO  
      BCSCTL2 = 0x0;
      BCSCTL1 |= DIVA_3;                        // ACLK = VLO/8
      
      TACCTL2 &= ~CCIFG;                        // Clear capture flag
      while (!(CCIFG & TACCTL2));               // Test capture flag to skip 1st cycle
      TACCTL2 &= ~CCIFG;                        // Clear capture flag
      
      while (!(CCIFG & TACCTL2));               // Test capture flag to skip 2nd cycle
      start_count = TACCR2;                     // save hardware captured value
      TACCTL2 &= ~CCIFG;                        // Clear capture flag
      
      while (!(CCIFG & TACCTL2));               // Test capture flag to capture a good clock
      TACTL &= ~MC_3;                           // Stop timer
      stop_count = TACCR2;
      return(stop_count - start_count);         // return
    }
    
     
    This code example and others can be found at the following link and on the product folder page for the MSP430F2418 in the subsequent link.
     
    MSP430F2418 Code Examples:http://www.ti.com/litv/zip/slac151d
     
     
    I have also attached another example that configures the MSP430F2418 for sourcing the VLO on ACLK and putting the device into LPM3, just to highlight the differences between calibrating and not-calibrating the VLO.
     
    MSP430x261x_1_vlo.c:
    //******************************************************************************
    //  MSP430x26x Demo - Software Toggle P1.0, MCLK = VLO/8
    //
    //  Description; Pulse P1.0 with a 1/100 active duty cycle using software.
    //  Ultra-low frequency ~ 1.5kHz, ultra-low power active mode demonstrated. All 
    //  the 6 I/O ports are configured as low outputs to eliminate floating inputs.
    //  ACLK = VL0, MCLK = VLO/8 ~ 1.5kHz, SMCLK = n/a
    //
    //             MSP430F261x/241x
    //             -----------------
    //         /|\|              XIN|-
    //          | |                 |
    //          --|RST          XOUT|-
    //            |                 |
    //            |             P1.0|-->LED
    //            |        P5.4/MCLK|-->MCLK = VLO/8
    //            |        P5.6/ACLK|-->ACLK = VLO
    //
    //  B. Nisarga
    //  Texas Instruments Inc.
    //  September 2007
    //  Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.42A
    //******************************************************************************
    #include "msp430x26x.h"
    
    volatile unsigned int i;                    // volatile to prevent optimization
    
    void main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
      BCSCTL3 |= LFXT1S_2;                      // LFXT1 = VLOCLK
      IFG1 &= ~OFIFG;                           // Clear OSCFault flag
      
      __bis_SR_register(SCG1 + SCG0);           // Stop DCO
      BCSCTL2 |= SELM_3 + DIVM_3;               // MCLK = VLO/8
      
      P1DIR = 0xFF;                             // All P1.x outputs
      P1OUT = 0;                                // All P1.x reset
      P2SEL = 0;                                // All P2.x GPIO function
      P2DIR = 0xFF;                             // All P2.x outputs
      P2OUT = 0;                                // All P2.x reset
      P3DIR = 0xFF;                             // All P3.x outputs
      P3OUT = 0;                                // All P3.x reset
      P4DIR = 0xFF;                             // All P4.x outputs
      P4OUT = 0;                                // All P4.x reset
      P5DIR = 0xFF;                             // All P5.x outputs
      P5OUT = 0;                                // All P5.x reset
      P6DIR = 0xFF;                             // All P6.x outputs
      P6OUT = 0;                                // All P6.x reset
      
      P5SEL |= 0x50;                            // P5.4= MCLK option select
                                                // P5.6= ACLK option select
      for (;;)
      {
        P1OUT |= 0x01;                          // P1.0 set
        for (i = 10; i > 0; i--);               // Delay 1x
        P1OUT &= ~0x01;                         // P1.0 reset
        for (i = 1000; i > 0; i--);             // Delay 100x
      }
    }
    
  • Guido,

    I just updated this thread with the examples attached that I referenced previously.

**Attention** This is a public forum