我买的是msp430F5438的开发板,发现设置外部晶振时钟时晶振出错标志老是清不掉,一打开XT1晶振出错标志位OFIFG就自动置位,百死不得其解!我找了好多代码,包括教程,以及TI的。以下是TI官方代码,但仍然跳不出循环:
P7SEL |= 0x03; // Select XT1
UCSCTL6 &= ~(XT1OFF); // XT1 On
UCSCTL6 |= XCAP_3; // Internal load cap
// Loop until XT1,XT2 & DCO stabilizes
do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
UCSCTL6 &= ~(XT1DRIVE_3); // Xtal is now stable, reduce drive
缘何?缘何啊? |