//******************************************************************************
// MSP430F54x Demo - XT2 sources MCLK & SMCLK
//
// Description: This program demonstrates using XT2 to source MCLK. XT1 is not
// connected in this case.
//
// By default, LFXT1 is requested by the following modules:
// - FLL
// - ACLK
// If LFXT1 is NOT used and if the user does not change the source modules,
// it causes the XT1xxOFIFG flag to be set because it is constantly looking
// for LFXT1. OFIFG, global oscillator fault flag, will always be set if LFXT1
// is set. Hence, it is important to ensure LFXT1 is no longer being sourced
// if LFXT1 is NOT used.
// MCLK = XT2
//
// MSP430F5438
// -----------------
// /|\ | |
// | | |
// ---|RST |
// | XT2IN|-
// | | HF XTAL (455kHz - 16MHz)
// | XT2OUT|-
// | |
// | P11.1|--> MCLK = XT2
// | P11.2|--> SMCLK = XT2
//
// M Smertneck / W. Goh
// Texas Instruments Inc.
// September 2008
// Built with CCE Version: 3.2.2 and IAR Embedded Workbench Version: 4.11B
//******************************************************************************
#include "msp430x54x.h"
void main(void)
{
unsigned int i;
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P11DIR = BIT1+BIT2; // P11.1-2 to output direction
P11SEL |= BIT1+BIT2; // P11.1-2 to output SMCLK,MCLK
P5SEL |= 0x0C; // Port select XT2
UCSCTL6 &= ~XT2OFF; // Ena××e XT2 even if not used
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 XT2 & DCO stabilize
do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
for(i=0;i<0xFFFF;i++); // Delay for Osc to stabilize
}while (SFRIFG1&OFIFG); // Test oscillator fault flag