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.

Selecting DCO Range

Other Parts Discussed in Thread: MSP430F5438A

I am using MSP430F5438A. one example code that i have doubt in is given below

#include  "msp430x54xA.h"

void main(void)
{
  WDTCTL = WDTPW+WDTHOLD;                   // Stop WDT
  P1DIR |= BIT0;                            // P1.0 output
  P11DIR |= 0x07;                           // ACLK, MCLK, SMCLK set out to pins
  P11SEL |= 0x07;                           // P11.0,1,2 for debugging purposes.

  UCSCTL3 |= SELREF_2;                      // Set DCO FLL reference = REFO
  UCSCTL4 |= SELA_2;                        // Set ACLK = REFO

  __bis_SR_register(SCG0);                  // Disable the FLL control loop
  UCSCTL0 = 0x0000;                         // Set lowest possible DCOx, MODx
  UCSCTL1 = DCORSEL_5;                      // Select DCO range 16MHz operation
  UCSCTL2 = FLLD_1 + 249;                   // Set DCO Multiplier for 8MHz
                                            // (N + 1) * FLLRef = Fdco
                                            // (249 + 1) * 32768 = 8MHz
                                            // 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 8 MHz / 32,768 Hz = 250000 = MCLK cycles for DCO to settle
  __delay_cycles(250000);

  // Loop until XT1,XT2 & DCO fault flag is cleared
  do
  {
    UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG);
                                            // Clear XT2,XT1,DCO fault flags
    SFRIFG1 &= ~OFIFG;                      // Clear fault flags
  }while (SFRIFG1&OFIFG);                   // Test oscillator fault flag
    
  while(1)
  {
    P1OUT ^= BIT0;                          // Toggle P1.0
    __delay_cycles(600000);                 // Delay
  }
}
The program sets the DCO range as 16MHz by selecting DCORSEL_5.
I checked in the datasheet. The maximum frequency range for the DCORSEL = 5, DCO = MOD =0 is 2.5 MHz to 6.0 MHz.

Please tell me that the range given as 16MHz correct ? Otherwise where am i interpreting things wrong ?

  • Hi Ankit,

    Yes, the code sets the correct DCO range for 16MHz DCO.

    The specification you mentioned from the data sheet applies only to DCO = MOD = 0.  The FLL automatically modifies both fields (DCO and MOD) as needed to reach the target of 16.384MHz, while staying in DCORSEL 5.  The very next parameter in the data sheet is for DCO = 31 (still DCORSEL 5).  The DCO will be at least 23.7 MHz and at most 54.1MHz for these settings.

    So DCORSEL 5 can always reach any frequency between 6.0 MHz and 23.7 MHz, regardless of supply voltage, temperature, and part-to-part variation.

    Jeff

  • Hi Jeff,
    For the value of DCORSEL 5  the range given is 2.5 to 6 MHz.. then how do we reach 16MHz ? 
    Also how did you infer that the value is given for 16MHz ? ( i could say it only because it was given as a comment )

    Ankit 

  • Hi again Ankit,

    DCORSEL=5, DCO=0,  MOD=0:  Min  2.5 MHz / Max  6.0 MHz

    DCORSEL=5, DCO=31, MOD=X:  Min 23.7 MHz / Max 54.1 MHz

    Both are DCORSEL 5.  So DCORSEL 5 is guaranteed to be able to hit as low as 6 MHz and as high as 23.7 MHz.  Therefore, DCORSEL 5 is a suitable setting if the target DCO rate is 16.384 MHz.

    If that's more clear now, then maybe go back and re-read my first response.  It should make more sense now.  ;-)

    Jeff

**Attention** This is a public forum