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.

DCO Frequency Accuracy

Other Parts Discussed in Thread: MSP430F5359

I am using an MSP430F5359 with a 32khz watch crystal connected to XT1.  I use the following code to initialize the clocking system:

    while(BAKCTL & LOCKBAK)                    // Unlock XT1 pins for operation
        BAKCTL &= ~(LOCKBAK);
    UCSCTL6 |= XCAP_3;
    UCSCTL6 &= ~(XT1OFF);           // XT1 On
    UCSCTL3 = 0;                              // FLL Reference Clock = XT1
    __bis_SR_register(SCG0);          // Disable the FLL control loop
    // Initialize DCO to 20MHz  
    UCSCTL0 = 0x0000;                         // Set lowest possible DCOx, MODx
    UCSCTL1 = DCORSEL_6;               // Select DCO range 40MHz operation
    UCSCTL2 |= FLLD_1 + 609;             // Set DCO Multiplier for 20MHz
                                            // (N + 1) * FLLRef = Fdco
                                            // (609 + 1) * 32768 = 19.988MHz
                                            // Set FLL Div = fDCOCLK/2
    __bic_SR_register(SCG0);                  // Enable the FLL control loop
    // Worst-case settling time for the DCO when the DCO range bits have been
    // changed is n x 32 x 32 x f_MCLK / f_FLL_reference. See UCS chapter in 5xx
    // UG for optimization.
    // 32 x 32 x CPUFREQ * 1 MHz / 32,768 Hz = MCLK cycles for DCO to settle
    __delay_cycles(32 * 32 * 20000000UL / 32768);
    
    // Loop until XT1,XT2 & DCO fault flag is cleared
    do
    {
        UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);
                                                // Clear XT2,XT1,DCO fault flags
        SFRIFG1 &= ~OFIFG;                      // Clear fault flags
    }while (SFRIFG1&OFIFG);                   // Test oscillator fault flag

With all that, and then routing the SMCLK out to a GPIO pin, I observe a clock frequency of 20.98MHz rather than the expected 19.98MHz.  Is the frequency really supposed to be off by that much?  Will the frequency be consistent from MSP to MSP?

Thanks,

Chris

  • For the DCO to use with FLL, there must first be a stable reference clock. Testing this clock at the end of the setup, at the same time with the DCO, is not good enough.

    For an accurate -en correct- frequency of the crystal oscillator, the correct Load-capacitors should be placed to be respectively set.
    A crystal oscillator can be started with the maximum drive current (default), if no more oscillator error this can be reduced.

    Before increasing the frequency of the DCO, Vcore must first be set to the desired voltage corresponding to the target frequency. Also make sure that the right capacitor is placed at the Vcore pin.
    The frequency accuracy of the DCO is solely dependent on the used crystal, and its frequency.
  • Hello,

    Thanks for getting back to me so quickly. I left off the Vcore adjustment in my example above to keep the code simpler. But, yes, I am setting the VCore up to the highest setting, one step at a time. I've set ACLK to be XT1 and routed ACLK out a gpio pin. The frequency there is pretty stable at 32768Hz. My oscilloscope shows 32678.7 to 32768.8.
    I was concerned that the issue may be my hardware, so I ran my code on the TI Eval board (MSP-TS430PZ100C) with the supplied crystal installed. The crystal package listed 12.5pf as the load cap, so the full drive strength should be okay as I understand it. Also, the TI board (as with my board) has the recommended CVcore cap of 470nf installed.
    The resulting SMCLK frequency I get out is very stable, it's just at the wrong frequency. I was expecting 19.988MHz per my configuration, but I'm consistently seeing the 20.98MHz out.
    This just doesn't seem normal to me.

    Any other ideas of what I should check?

    Thanks,
    Chris.
  • What you can try is to write down the values of the DCO and MOD bits, to turn off the FFL, and to carry out the oscillator with these values.

    Optionally you can change the DCO and MOD bits to see if you can get to the proper frequency (without FLL).

  • I would test various Multiplier values around 609 to see how it changes result - maybe results will give idea about what's wrong.

    > UCSCTL1 = DCORSEL_6; // Select DCO range 40MHz operation
    You shall consider to test with DCORSEL_5 which also includes 19.988MHz in range.
    Other option would be to run DCO at double rate and divide result by 2 to get desired frequency.

**Attention** This is a public forum