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.

20 Mhz not working

Other Parts Discussed in Thread: MSP430F5325

Dear All,

         For MSP430F5325 we used the crystal oscillator 32768Hz in low frequency mode (XT1) and DVCC

of  3.3V. Using 32768Hz crystal we are able to generate SMCLK from FLL upto 18 Mhz  but when we try to go for the higher frequencies that is 20 Mhz/25 Mhz  are not working .

kindly refer the below code for your reference ,kindly note commented part is for 18 Mhz which is working fine ,we have a problem for 20Mhz and higher frequencies.

Kindly help to resolved the problem.

 

 

//////////////////////Defination

  // For 18   Mhz

/* # define DCO_RANGE        DCORSEL_7            //DCORSEL_7 for  16.77 MHZ

# define DCO_MULTIPLIER       551                    //551 for 18.055 MHZ

*/

// for 20 Mhz

# define DCO_RANGE        DCORSEL_4              //DCORSEL_4   for  20.021 MHZ

# define DCO_MULTIPLIER       611                    //611 for 20.021 MHZ

 

 

///////////////////////////////////////// DC0 stabilization start

                                  P5SEL |= BIT4+BIT5;                       // Select XT1

 

                                  UCSCTL6 |= BIT7+BIT6;                     // Reduce XT1 DRIVE STRENGTH

                                  UCSCTL6 &= ~BIT5;                         // XT1 mode select ,XTS=0

                                  UCSCTL6 &=~BIT4;                          //

 

                                  UCSCTL6 &= ~(XT1OFF);                     // XT1 On

                                  UCSCTL6 |= XCAP_3;                        // Internal load cap

                                  UCSCTL3 = 0;                              // FLL Reference Clock = XT1

 

                                  // Loop until XT1,XT2 & DCO stabilizes - In this case loop until XT1 and DCo settle

                         do

                          {

                                UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);       // Clear XT2,XT1,DCO fault flags                                                                                                                                                                 

                                           

                                                SFRIFG1 &= ~OFIFG;                      // Clear fault flags

                      } while (SFRIFG1&OFIFG);                   // Test oscillator fault flag

 

                                   UCSCTL6 &= ~(XT1DRIVE_3);                 // Xtal is now stable, reduce drive strength

 

                                  UCSCTL4 |= SELA_0;                        // ACLK = LFXT1 (by default)

 

 

  ////////////////////////////////////Start of DCo 20Mhz (locked to 32Khz by FLL/////////////////////////////

 

                  //UCSCTL3 = SELREF_0;                       // Set DCO FLL reference = XT1CLK  (external watch 32kHz)

                  UCSCTL4 |= SELA_0;                        // Set ACLK = XT1CLK  (external watch 32kHz)

 

                  __bis_SR_register(SCG0);                  // Disable the FLL control loop

               

                  UCSCTL0 = 0x0000;                         // Set lowest possible DCOx, MODx

         

 

 

////////////////////////////////////////////////// /////////////////////////              18MHz       

   /*         UCSCTL1 = DCO_RANGE;                                          //DCORSEL_7;  

           UCSCTL2 = FLLD_1 + DCO_MULTIPLIER;             //  551; //18055168Hz

*/

///////////////////////////////////////////////////// 20 Mhz

            UCSCTL1 = DCO_RANGE;                                          //DCORSEL_4;  

           UCSCTL2 = FLLD_1 + DCO_MULTIPLIER;              //611   //    20021248                

    

                  __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 stabilizes - In this case only DCO has to stabilize

                  do

                  {

                                UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);

                                                                                          // Clear    XT2,XT1,DCO fault flags

                                SFRIFG1 &= ~OFIFG;                      // Clear fault flags

                  } while (SFRIFG1&OFIFG);                   // Test oscillator fault flag

 

  /////////////////////////////////End of DCO  stabilization/////////////////////

  • hhh ggg said:
    # define DCO_RANGE        DCORSEL_4              //DCORSEL_4   for  20.021 MHZ

    Take anothe rlook at the daatsheet.

    It tells you that for DCORSEL_4, the maximum frequency for DCOx=31 is between 12.3 and 28.2MHz. So 28.2MHz are possible with DCORSEL_4, but only 12.3 are guaranteed. On your MSP, 18MHz seems to be the limit.

    For 20MHz, use DCORSEL_5, it guarantees 6 to 23.7MHz but maybe offer 2.5 to 54MHz.

    You shouldn't go above 23.7MHz anyway, as FLL and DCO modulation is an average of two frequencies, where one is (obviously) higher than the target. If you would go for 25MHz, one of the two modulated frequencies would be >25MHz which is outside the specs, possibly crashing the CPU

  • You may also need to make sure the core voltage is suitable for the MCLK frequency you are going to use.

  • Thanks Jens & old yellow cow for repliies,

    We tried the both suggesion that is we have maked the DCORSEL_5 with Dco multiplier 611 and we already increased the core  voltage level to 3 but there is no improvement for above 18 Mhz smclk's. we didnt understand the issue.

    One thing we observed in our code that when we dubug the code and suspend the debugging we always find the code is stuck up in below loop.

    pl refer previous detail code ,

      // Loop until XT1,XT2 & DCO stabilizes - In this case only DCO has to stabilize

                      do

                      {

                                    UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);

                                                                                              // Clear    XT2,XT1,DCO fault flags

                                    SFRIFG1 &= ~OFIFG;                      // Clear fault flags

                      } while (SFRIFG1&OFIFG);                   // Test oscillator fault flag

     

    Kindly suggest the solution ,

    Awaiting reply.

  • hhh ggg said:
    there is no improvement for above 18 Mhz smclk's

    It should work now. Well, let's see what else might be wrong...

    hhh ggg said:
    UCSCTL6 |= BIT7+BIT6;                     // Reduce XT1 DRIVE STRENGTH

    Reduce? This sets maximum! However, it is actually better.

    Why don't you use the predefined values instead of anonymous bits? It is sooo much easier to read:

    UCSCTL6 |= XT1DRIVE_3;

    Also, please don't use arithmetic add operator ('+') for combining bit values. use the bitwise OR operator instead ('|'). Adding only coincidentally works (and may under some circumstances lead to problems that are hard to track down)

    hhh ggg said:
    /* # define DCO_RANGE        DCORSEL_7            //DCORSEL_7 for  16.77 MHZ
    # define DCO_MULTIPLIER       551                    //551 for 18.055 MHZ
    */

    I'm not quite sure how the preprocessor handles #defines in block comments.
    In my own source code, unused defines are wrapped with #if 0 directives, not block comments.
    And the 551 multiplier definition in it would match your 18MHz result.

    Do you get a redefinition warning?

    hhh ggg said:
    when we dubug the code and suspend the debugging we always find the code is stuck up in below loop.

    So apparently you have an oscillator fault. Which one? Check the UCSCTL7 register for which OFFG bit is set.
    If it is DCOFFG, then DCOx is either 0 or 31 (indicating that the FLL is not working or latchign against the min/max of the current DCORSEL). If it is LFXT1OFFG, then the crystal isn't working and the FLL runs on REFO fallback.

    hhh ggg said:
     UCSCTL2 = FLLD_1 + DCO_MULTIPLIER;              //611   //    20021248               

    Why FLLD_1? This is an additional divider on DCO. This means, you are pushing the DCO for 40MHz. The default DCOCLKDIV will then source MCLK and SMCLK with DCOCLK/2. If you want the DCO to run on 20MHz, don't set FLLD. Then DCOCLKDIV will be = DCOCLK and the DCO will run on 20MHz.

    (the default settings configure the DCO for 2MHz (32768*31*2) and use DCOCLKDIV as source for MCLK and SMCLK, which is 1MHz then. it gives a bit less jitter)

**Attention** This is a public forum