诸位高手大侠,向您们请教一下:MSP430FR2XXX系列MCU怎样用外部晶振?
按使用手册写了一段小程序,想将MSP430FR2111、MSP430FR2433分别用8MHz、16MHz的外部晶振运行,但怎么也振荡不起来。。。。恳请诸位高手大侠具体指点,致谢
void Init_Clock()
{
P2SEL0 |= BIT0 | BIT1; // set XT1 pin as second function
P2SEL0 |= BIT6 | BIT7; // set XT1 pin as second function
// do
// {
// CSCTL7 &= ~(XT1OFFG | DCOFFG); // Clear XT1 and DCO fault flag
// SFRIFG1 &= ~OFIFG;
// } while (SFRIFG1 & OFIFG); // Test oscillator fault flag
CSCTL1 &= ~(DCORSEL_7); // Clear DCO frequency select bits first
CSCTL6 |= XT1HFFREQ_2 + XT1BYPASS_1 + XTS_1 ; // >6 MHz to 16 MHz +XT1 sources externally from pin
CSCTL6 &=~(XT1AUTOOFF+XT1AGCOFF);
CSCTL3 |= SELREF__XT1CLK; // Set XT1CLK as FLL reference source
CSCTL1 |=DCORSEL_3; // DCORSEL_3; // Set DCO = 8MHz
CSCTL2 = FLLD_0 + 243; // DCODIV = 8MHz
do
{
__delay_cycles(7 * 31 * 8); // Requires 7 reference clock delay before
// polling FLLUNLOCK bits
// @8 MHz, ~1736 cycles
} while(CSCTL7 & (FLLUNLOCK0 | FLLUNLOCK1));// Poll until FLL is locked
//CSCTL4 = SELMS__DCOCLKDIV | SELA__XT1CLK; // Set ACLK = XT1CLK = 32768Hz
// DCOCLK = MCLK and SMCLK source
CSCTL5 |= DIVM_0 | DIVS_0; // MCLK = DCOCLK = 8MHZ,
// SMCLK = MCLK/8 = 1MHz
}
|