TI中文支持网
TI专业的中文技术问题搜集分享网站

为什么MSP430单片机一开高频模式(XTS置位),XT1HFOFFG就会置位

为什么MSP430单片机一开高频模式(XTS置位)并且设置了XT1后,XT1HFOFFG就会置位

 

以下是CCS上的MSP430F5438A的例程(删掉了两处),这个程序的运行后发现UCSCTL7中的XT1HFOFFG标志位一直为1,导致程序死在}while (SFRIFG1&OFIFG); 这一步。附图中为UCSCTL7寄存器的值。希望解答,谢谢!

 

//  MSP430F543xA Demo – LFXT1 HF Xtal + Internal DCO

#include "msp430x54xA.h"

//#include "hal_pmm.h" 此处删掉   此处删掉   此处删掉   此处删掉    此处删掉    此处删掉  此处删掉  此处删掉  此处删掉

void main(void)

{  

 WDTCTL = WDTPW + WDTHOLD;                                       // Stop WDT

  // SetVCore(PMMCOREV_2);       // Set VCore to 1.8MHz for 20MHz   此处删掉 此处删掉  此处删掉 此处删掉 此处删掉 此处删掉 此处删掉   

P11DIR = BIT2 + BIT1 + BIT0;                                                 // P11.2,1,0 to output direction  

P11SEL = BIT2 + BIT1 + BIT0;                                                 // P11.2 to output SMCLK, P11.1                                            

                                                                                               // to output MCLK and P11.0 to                                            

                                                                                              // output ACLK  

 P7SEL |= 0x03;                                                                    // Port select XT1  

 UCSCTL3 |= SELREF_2;                                                     // FLL Ref = REFO  

UCSCTL6 &= ~XT1OFF;                                                          // Set XT1 On  

UCSCTL6 |= XT1DRIVE_3 + XTS;                                         // Max drive strength, adjust

                                                                                                // according to crystal frequency.

                                                                                                // LFXT1 HF mode

                                                                                                    // 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

  UCSCTL4 = SELA_0 + SELS_4 + SELM_0;                                                                                       // Select ACLK = LFXT1

                                                                                                                                                                 //  SMCLK = DCO                                            

                                                                                                                                                                 //   MCLK = LFXT1

  while(1);                                                                   // Loop in place

 }

Hardy Hu:

你好!

XT1OFFG置位说明XT1没有正常的起振。

1.你的晶体或者晶振频率是多少,如果用 XT1DRIVE_3则其典型频率应落在24-32MHz。

2.如果外部时钟是有源晶振,则需要设置XT1BYPASS位

3.如果外部时钟是无源晶体,则需要外加负载电容。

4.MCLK,SMCLK,ACLK等需要通过FLL处理吗?来源是REFO还是XT1?

user3546312:

回复 Hardy Hu:

XT1接的是32768HZ的晶振,XT2接的是4M的,都有负载电容。主要问题是要是XT1LFOFFG是没有报错,是不是XT1HFOFFG和XT1LFOFFG指挥有一个置1而不会两个都置1?

Hardy Hu:

回复 user3546312:

你好!

如果你的XT1是32768HZ,那么XT1就不能配置为HF模式,要配置为LF模式,XTS清零。

UCSCTL6 |= XT1DRIVE_3 + XTS;这句话就是为设置HF做的。

user3546312:

回复 Hardy Hu:

你好,那再问下HF模式只是针对XT1接高频晶振时使用对吗?HF模式是不是与XT2没有任何关系?

xueyang zhang:

回复 Hardy Hu:

如果xt1的io要用于GPIO怎么设置,可以不外接晶体吗?不外接晶体,在msp430f5438a中如何设置。

赞(0)
未经允许不得转载:TI中文支持网 » 为什么MSP430单片机一开高频模式(XTS置位),XT1HFOFFG就会置位
分享到: 更多 (0)