void check_clk(void)
{
unsigned int i;
P5SEL|=BIT2+BIT3; //P52 P53XT2
P5DIR&=~BIT2;
P7SEL|=BIT0+BIT1; //P70 P71XT1
P7DIR&=~BIT0;
UCSCTL1|=DCORSEL_7;
UCSCTL2|=FLLD_1;
UCSCTL3|=FLLREFDIV_1;
UCSCTL4 |= SELA_0 + SELS_5 + SELM_5; // SMCLK=MCLK=XT2
UCSCTL5|=DIVPA_0+DIVS_0+DIVM_0; //ACLK=32768/1 MCLK=SMCLK=XT2=25M/n;
UCSCTL6&= ~(XT2OFF+XT2OFF); //打开XT1 XT2
UCSCTL6 |= XT2DRIVE_3+XT2BYPASS+XT1DRIVE_1+XT1BYPASS;
do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG );
SFRIFG1 &= ~OFIFG; // 清除振荡器失效标志
for (i = 0xFF; i > 0; i--); // 延时,等待XT2起振
} while (SFRIFG1 & OFIFG); // 判断XT2是否起振
UCSCTL4 |= SELA_0 + SELS_5 + SELM_5; // SMCLK=MCLK=XT2
}
电容=22p 晶振都换的几个但是XT1和XT2都没起振,示波器也检测不到(一端接地,一端接晶振)
程序会一直在while语句里面出不来。