|
7楼
![](static/image/common/ico_lz.png)
楼主 |
发表于 2019-1-4 16:06:35
|
只看该作者
时钟配置的代码如下,两种方式都进行了对比,但是还是存在上述问题。感觉像中断向量配置,求大神支招!!!
/******************************************************************************
**函数名称:void stateFault()
**函数功能:内部晶振函数,配置系统时钟
**函数输入:无
**函数输出:无
**函数备注:
******************************************************************************/
void cpmu_init(void)
{
// Wait for stable supply after power up
while (GDUF_GLVLSF)
GDUF_GLVLSF = 1;
CPMUREFDIV_REFDIV = 0; // 内部时钟为1MHz
CPMUREFDIV_REFFRQ = 0; // 0 for 1MHz - 2MHz
CPMUSYNR_SYNDIV = 49; // 100 MHz VCO output
CPMUSYNR_VCOFRQ = 3;
CPMUPOSTDIV_POSTDIV = 0; // 100MHz
//CPMUOSC_OSCE = 1;
//CPMUHTCTL_HTE = 1;
// Wait for oscillator to start up (UPOSC=1) and PLL to lock (LOCK=1).
//while (CPMUIFLG_UPOSC == 0) {};
while (CPMUIFLG_LOCK == 0) {};
CPMURFLG = 0x60; //Clear PORF and LVRF
}
/******************************************************************************
**函数名称:void stateFault()
**函数功能:外部晶振函数,配置系统时钟
**函数输入:无
**函数输出:无
**函数备注:
******************************************************************************/
//void cpmu_init(void)
//{
// // Wait for stable supply after power up
// while (GDUF_GLVLSF)
// GDUF_GLVLSF = 1;
//
//
// CPMUREFDIV_REFDIV = 15; // 16MHz => 1MHz
// CPMUREFDIV_REFFRQ = 0; // 0 for 1MHz - 2MHz
// CPMUSYNR_SYNDIV = 49; // 100 MHz VCO output,fVCO = 2*fREF*(SYNDIV + 1)
// CPMUSYNR_VCOFRQ = 3; // b11:80MHz < fVCO<= 100MHz; b01:48MHz < fVCO <= 80MHz
// CPMUPOSTDIV_POSTDIV = 0; // 100MHz
//
// CPMUOSC_OSCE = 1; //This bit enables the external oscillator,外部晶振使能位
// CPMUHTCTL_HTE = 1; //高温传感器是否启用?
//
// // Wait for oscillator to start up (UPOSC=1) and PLL to lock (LOCK=1). while (CPMUIFLG_UPOSC == 0) {};
// while (CPMUIFLG_LOCK == 0) {};
// CPMURFLG = 0x60; //Clear PORF and LVRF
//} |
|