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.
Tool/software: Code Composer Studio
Hi,
I am trying to configure my MSP430F5529 MCU with an external crystal oscillator on port pins P5.2 and P5.3 (XT2IN and XT2OUT). The external crystal oscillator is a 16MHz XTAL.I looked through the MSP430F5529 user's guide and datasheet, and I've added some of my UART code below. I also have SMCLK source selected and a divider of 2. Do I need to add any additional control register fields to achieve my initialization?
P3SEL |= BIT3 + BIT4; // P3.3 and P3.4 -> UART Ports P5SEL |= BIT2 + BIT3; // P5.2 -> XT2IN and P5.3 -> XT2OUT UCSCTL6 &= ~XT2OFF; // Set XT2 On UCSCTL4 = SELS_5; // SELS_5 -> XT2CLK (Selects SMCLK) UCSCTL5 = DIVS_1; // DIVS_1 -> SMCLK source divider (divide by 2) UCSCTL6 = XT2BYPASS | XT2DRIVE_1; //** Test Conditions for Crystal Oscillator XT2 ** // in the frequency range of 8 to 16 MHz // XT2BYPASS -> XT2 sourced from external crystal // Increased drive strength XT2 oscillator UCA0CTL1 |= UCSWRST; // **Put state machine in reset** UCA0CTL1 |= UCSSEL_2; // Clock Source SMCLK UCA0BR0 = 69; // 8MHz 115200 UCA0BR1 = 0; // 8MHz 115200 UCA0MCTL = UCBRS_4 + UCBRF_0; // Modulation UCBRSx = 4 UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine** UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt
Thanks
You need to wait until the crystal has started up, and then clear the fault flag to disable the fail-safe fallback (see section 5.2.12 of the User's Guide).
The example program MSP430F55xx_UCS_08.c shows how to do this:
... P5SEL |= BIT2+BIT3; // Port select XT2 UCSCTL6 &= ~XT2OFF; // Enable XT2 UCSCTL3 |= SELREF_2; // FLLref = REFO // Since LFXT1 is not used, // sourcing FLL with LFXT1 can cause // XT1OFFG flag to set UCSCTL4 |= SELA_2; // ACLK=REFO,SMCLK=DCO,MCLK=DCO // Loop until XT1,XT2 & DCO stabilizes - in this case loop until XT2 settles do { UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG); // Clear XT2,XT1,DCO fault flags SFRIFG1 &= ~OFIFG; // Clear fault flags }while (SFRIFG1&OFIFG); // Test oscillator fault flag UCSCTL6 &= ~XT2DRIVE0; // Decrease XT2 Drive according to // expected frequency UCSCTL4 |= SELS_5 + SELM_5; // SMCLK=MCLK=XT2 ...
**Attention** This is a public forum