三角波
示波器说检测到了正弦波……
我的晶振是24MHz 单片机是MSP430F5438A
程序如下:
- void SystemClockInitial()
- {
- P5SEL |= 0x0c; //选择P5.2,P5.3为XT1引脚
- P7SEL |= 0X03; //选择P7.0,P7.1为XT2引脚
- P11DIR |= 0x07; //设置P11为输出
- P11SEL |= 0x07; //选择P11口的第二功能 0:ACLK 1:MCLK 2:SMCLK
-
- __bis_SR_register(SCG0); //关闭FLL
-
- UCSCTL0 = 0x0000; //DC0 = 0 MOD = 0
- UCSCTL1 = DCORSEL_0; //RSEL = 0 0.07~0.20MHz 70K~200KHz
- UCSCTL2 = 0x1031; //D = 1 N = 49
- UCSCTL3 = SELREF__REFOCLK + FLLREFDIV__16; //32768Hz 32768 / 16 * 1 * 50 = 102.4KHz
- UCSCTL4 = SELA__DCOCLK + SELM__XT1CLK + SELS__XT2CLK; //ACLK = XT1CLK = 32768 MCLK = SMCLK = XT2CLK = 24MHz
- UCSCTL5 = DIVPA__16 + DIVA__1 + DIVM__2 + DIVS__1;
- UCSCTL6 = XT2DRIVE_2 + XT1DRIVE_1 + XCAP_3;
- UCSCTL6 &= ~(XT1OFF + XT2OFF);
- UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG);
- while(SFRIFG1&OFIFG)
- {
- UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG);
- SFRIFG1 &= ~OFIFG;
- }
- __bic_SR_register(SCG0);
- }
复制代码
[
本帖最后由 yang坤兴 于 2012-9-9 16:53 编辑 ]
此帖出自
小平头技术问答
一周热门 更多>