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.
void check_clk(void)
{
P11SEL |= BIT0+BIT1+BIT2; //
P11DIR = BIT0+BIT1+BIT2; // P11.1-2 to output direction
P5SEL |= 0x0C; // Port select XT2
P7SEL |= 0x03; // Select XT1
UCSCTL6 &= ~(XT1OFF+XT2OFF); // XT1 On
UCSCTL6 |= XCAP_3;
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
do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
_NOP();_NOP();_NOP();_NOP();_NOP();
_NOP();_NOP();_NOP();_NOP();_NOP();
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
UCSCTL6 &= ~(XT2DRIVE0+XT1DRIVE_3); // Decrease XT2 Drive according to
UCSCTL4 |= SELS_5 + SELM_5+SELA_0; // SMCLK=MCLK=XT2
UCSCTL5 |= DIVPA_0+DIVS_0+DIVM_1; // SMCLK=MCLK=XT2=25
}
我XT2接的是25M晶振,时钟从引脚输出来都是正常,但是当我将MCLK改为:DIVM_1 即MCLK=12.5,程序可以正常运行。
但是当我将改为:DIVM_0 设置MCLK=25M 时,程序就会跑飞。