static void App_ClkCfg(void)
{
stc_sysctrl_sysclk_source_init_t stcSysClkSrc = {0};
stc_sysctrl_clk_init_t stcSysClk = {0};
/*!< 系统时钟源初始化 */
/*!< FOUT = FIN * MULM / DIVN / OD = 4 * 48 / 1 / 2^2 = 48MHz */
stcSysClkSrc.u32SysClkSourceType = SYSCTRL_SYSCLK_SOURCE_TYPE_XTH|\
SYSCTRL_SYSCLK_SOURCE_TYPE_PLL;
stcSysClkSrc.u32RCHState = SYSCTRL_RCH_TRIM_24MHz|\
SYSCTRL_RCH_DIV2;
stcSysClkSrc.u32RCLState = SYSCTRL_RCL_TRIM_32p8KHz |\
SYSCTRL_RCL_WAITCYCLE256;
stcSysClkSrc.u32XTHState = SYSCTRL_XTH_DRV2 |\
SYSCTRL_XTH_8t16MHz |\
SYSCTRL_XTH_WAITCYCLE3;
stcSysClkSrc.u32PLLState = SYSCTRL_PLL_MULM_CONFIG(50) | SYSCTRL_PLL_DIVN_CONFIG(1) | SYSCTRL_PLL_OEN_ON
| SYSCTRL_PLL_WAITCYCLE_CONFIG(7) | SYSCTRL_PLL_OD_CONFIG(2) | SYSCTRL_PLL_SRC_RCH;
while (Ok != SYSCTRL_SysClkSrcInit(&stcSysClkSrc)) /*!< 时钟源初始化 */
{
;
}
/*!< 系统时钟初始化 */
stcSysClk.u32ClockType = SYSCTRL_CLOCKTYPE_SYSCLK |\
SYSCTRL_CLOCKTYPE_HCLK |\
SYSCTRL_CLOCKTYPE_PCLK0 |\
SYSCTRL_CLOCKTYPE_PCLK1;
stcSysClk.u32SysClkSource = SYSCTRL_SYSCLK_SOURCE_PLL;//SYSCTRL_SYSCLK_SOURCE_RCH;
stcSysClk.u32HClkDiv = SYSCTRL_SYSCLK_HCLK_PRS1;
stcSysClk.u32PClk0Div = SYSCTRL_SYSCLK_PCLK0_PRS4;
stcSysClk.u32PClk1Div = SYSCTRL_SYSCLK_PCLK1_PRS2;
stcSysClk.u32WaitCycle = SYSCTRL_FLASH_WAIT_CYCLE2;
SYSCTRL_SysClkInit(&stcSysClk);
}
请教各位大神:修改例程,本意是想用外部晶振的,但是启动后,短路外部晶振,单片机正常工作,这是哪里配置错了?想用外部8M 倍频到80或84M 要怎么设置? |