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.

Problems of initializing MSP430F5529 with external oscillator of 20 Mhz

Other Parts Discussed in Thread: MSP430F5529

Hi, I am working on a project that needs to use an external oscillator of 20Mhz. The chip outputs the MCLK to P7.7.

The clock seems running OK if I commented "analog_tx();" in the while loop,  but it becomes distorted or unstable when I put that line back in. If I add more lines in subroutine

analog_tx(), the chip wouldn't even run.

I wonder if I have initialized the clock wrong, or it was an oscillator problem. Thank you for your help!

The code is:


#include "msp430f5529.h"

void SetVCoreUp(unsigned int level);
void analog_tx (void);

unsigned int level1 = 1;
unsigned int level2 = 2;
unsigned int level3 = 3;

void main(void)
{
    WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog timer
   
    SetVCoreUp(level1);
    SetVCoreUp(level2);
    SetVCoreUp(level3);
    
    P2DIR |= BIT2;                            // SMCLK set out to pins
    P2SEL |= BIT2;                        
    P7DIR |= BIT7;                            // MCLK set out to pins
    P7SEL |= BIT7;
   
    P1SEL &= ~BIT0; // P1.0 set as I/O
    P1DIR |= BIT0;  // P1.0 as output
      
      P1SEL &= ~BIT1; // P1.1 set as I/O
    P1DIR |= BIT1;  // P1.1 as output
 
    P5SEL |= BIT2+BIT3;                       // Port select XT2
    UCSCTL6 |= XT2BYPASS;
    UCSCTL6 &= ~XT2OFF; //enables xt2

   
    do {
        UCSCTL7 &= ~XT2OFFG;        // Clear XT2 fault flags
        __delay_cycles(10000);
    }while (UCSCTL7&XT2OFFG);
   
    UCSCTL5 = 0x0000; // divide by 1
    UCSCTL4 = SELA_5 + SELS_5 + SELM_5;

 
    __bis_SR_register(GIE);
      
    while(1) {
        analog_tx();
    }
   
}
void SetVCoreUp(unsigned int level)
{
  // Open PMM registers for write
  PMMCTL0_H = PMMPW_H;          
  // Set SVS/SVM high side new level
  SVSMHCTL = SVSHE + SVSHRVL0 * level + SVMHE + SVSMHRRL0 * level;
  // Set SVM low side to new level
  SVSMLCTL = SVSLE + SVMLE + SVSMLRRL0 * level;
  // Wait till SVM is settled
  while ((PMMIFG & SVSMLDLYIFG) == 0);
  // Clear already set flags
  PMMIFG &= ~(SVMLVLRIFG + SVMLIFG);
  // Set VCore to new level
  PMMCTL0_L = PMMCOREV0 * level;
  // Wait till new level reached
  if ((PMMIFG & SVMLIFG))
    while ((PMMIFG & SVMLVLRIFG) == 0);
  // Set SVS/SVM low side to new level
  SVSMLCTL = SVSLE + SVSLRVL0 * level + SVMLE + SVSMLRRL0 * level;
  // Lock PMM registers for write access
  PMMCTL0_H = 0x00;
}
void analog_tx (void)
{
    P1OUT ^= 0x01;
    P1OUT ^= 0x02;
}



  • Your analog_tx function causes two port pins to be toggled with a high frequency. (on 20MHz MCLK with around 500kHz). If these pins are driving LEDS, this will cause a significant HF ripple on VCC. maybe your VCC supply to the MSP becomes unstable and you experience brownouts. You should try adding another blocking capacitor on VCC directly near the MSP. Preferrably a lowESR type or a ceramic one. (speed is more important here than just plain capacitance, and electrolytic capacitors are rather slow due to high ESR.)

  • Hi Lei Niu,

    I noticed that you put XT2 in bypass mode.  What is the pk-pk signal of your oscillator?  Some oscillators generate only 1V pk-pk, which can cause the symptoms you describe if you use XT2 bypass mode.

    Jeff

  • Thank you for your help. We have just put a 22uF ceramic capacitor to stabilize VCC. The problem still exists. Sometimes, the master clock keeps switching between the DCO and the external oscillator, and after a while the chip failed.

  • The pk-pk signal of my oscillator is about 4V.

  • Lei Niu said:
    The pk-pk signal of my oscillator is about 4V.

    This is too much. The oscillator signal should be GND-based (no negative voltage) and must not exceed VCC (which is 3.6V at max). Else cross-currents will flow from XIN to VCC and latchup effects may occur. The switchng between XIN and DCO indicates that the crystal is detected being 'bad' for some time. Possibly a latchup effect.

**Attention** This is a public forum