本帖最后由 风无痕 于 2020-12-14 19:40 编辑
我这样配置之后芯片不运行了,只要将时钟切换到PLL,芯片就不运行 哪个大神求教
- void App_RCH24MHzToPll48MHz (void)
{
stc_sysctrl_pll_cfg_t stcPLLCfg;
///<============== 将时钟从RCH4MHz切换至RCH24MHz ==============================
///< RCH时钟不同频率的切换,需要先将时钟切换到RCL,设置好频率后再切回RCH
Sysctrl_SetRCLTrim(SysctrlRclFreq32768);
Sysctrl_ClkSourceEnable(SysctrlClkRCL, TRUE);
Sysctrl_SysClkSwitch(SysctrlClkRCL);
///< 加载目标频率的RCH的TRIM值
Sysctrl_SetRCHTrim(SysctrlRchFreq24MHz);
///< 使能RCH(默认打开,此处可不需要再次打开)
//Sysctrl_ClkSourceEnable(SysctrlClkRCH, TRUE);
///< 时钟切换到RCH
Sysctrl_SysClkSwitch(SysctrlClkRCH);
///< 关闭RCL时钟
Sysctrl_ClkSourceEnable(SysctrlClkRCL, FALSE);
///< 注意十分重要 当前时钟源HCLK大于24M:此处设置FLASH 读等待周期为1 cycle(前面已经配置,此处无需重复配置)
Flash_WaitCycle(FlashWaitCycle1);
stcPLLCfg.enInFreq = SysctrlPllInFreq20_24MHz; //RCH 24MHz
stcPLLCfg.enOutFreq = SysctrlPllOutFreq36_48MHz; //PLL 输出48MHz
stcPLLCfg.enPllClkSrc = SysctrlPllRch; //输入时钟源选择RCH
stcPLLCfg.enPllMul = SysctrlPllMul2; //24MHz x 2 = 48MHz
Sysctrl_SetPLLFreq(&stcPLLCfg);
Sysctrl_SetPLLStableTime(SysctrlPllStableCycle16384);
Sysctrl_ClkSourceEnable(SysctrlClkPLL, TRUE);
///< 时钟切换
Sysctrl_SysClkSwitch(SysctrlClkPLL);
Sysctrl_GetPClkFreq(); //获取PCLK时钟频率
}
|