|
MSP430FR5969如何只启动外部16M晶振HFXT
[复制链接]
我现在使用的是MSP430FR5969开发板进行前期调试,但是后期要使用MSP430FR5959,两者的差别就是MSP430FR5959没有LFXT管脚,可是我现在打算只使用HFXT,但程序总是死在晶振起振的循环里,如果HFXT和LFXT一起起振就没有问题,请各位老师指点,谢谢!
代码如下:
#include
int main(void)
{
WDTCTL = WDTPW | WDTHOLD;
// Configure GPIO
P1OUT = 0; P1DIR = 0xFF;
P2OUT = 0; P2DIR = 0xFF;
P3OUT = 0; P3DIR = 0xFF;
P4OUT = 0; P4DIR = 0xFF;
PJOUT = 0; PJDIR = 0xFFFF;
PJSEL0 |= BIT4 | BIT5|BIT6|BIT7 ; // For XT1
PM5CTL0 &= ~LOCKLPM5;
// Disable the GPIO power-on default high-impedance mode to activate
// previously configured port settings
PM5CTL0 &= ~LOCKLPM5;
CSCTL0_H = CSKEY >> 8; // Unlock CS registers
FRCTL0 = FRCTLPW | NWAITS_1;//使用16M晶振时需在设置之前添加此语句
CSCTL1 = DCOFSEL_4|DCORSEL; // Set DCO to 16 MHz
//CSCTL1 = DCOFSEL_6; // Set DCO to 8MHz
CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__HFXTCLK;
CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1; // Set all dividers to 1
CSCTL4 = HFXTOFF;
CSCTL4 &= ~(HFXTOFF);
do
{
CSCTL5 &= ~( HFXTOFFG); // Clear XT1 and XT2 fault flag
SFRIFG1 &= ~OFIFG;
}while (SFRIFG1&OFIFG); // Test oscillator fault flag程序死在此处
CSCTL0_H = 0; // Lock CS registers
while (1) {
P4OUT ^= BIT6; // Toggle LED
__delay_cycles(32768); // Wait 8,000,000 CPU Cycles
}
}
|
|