void App_SystemClkInit_PLL32M_byXTH(void)
{
stc_sysctrl_pll_cfg_t stcPLLCfg;
///< 切换时钟前(根据外部高速晶振)设置XTH频率范围,配置晶振参数,使能目标时钟
Sysctrl_SetXTHFreq(SysctrlXthFreq4_8MHz);
Sysctrl_XTHDriverCfg(SysctrlXtalDriver1);
Sysctrl_SetXTHStableTime(SysctrlXthStableCycle16384);
Sysctrl_ClkSourceEnable(SysctrlClkXTH, TRUE);
delay1ms(10);
stcPLLCfg.enInFreq = SysctrlPllInFreq6_12MHz; //XTH 8MHz
stcPLLCfg.enOutFreq = SysctrlPllOutFreq24_36MHz; //PLL 输出
stcPLLCfg.enPllClkSrc = SysctrlPllXthXtal; //输入时钟源选择XTH
stcPLLCfg.enPllMul = SysctrlPllMul4; //8MHz x 4 = 32MHz
Sysctrl_SetPLLFreq(&stcPLLCfg);
///< 当使用的时钟源HCLK大于24M:设置FLASH 读等待周期为1 cycle(默认值也为1 cycle)
Flash_WaitCycle(FlashWaitCycle1);
///< 使能PLL
Sysctrl_ClkSourceEnable(SysctrlClkPLL, TRUE);
///< 时钟切换到PLL
Sysctrl_SysClkSwitch(SysctrlClkPLL);
} |