整个函数如下:
void SysClockConfig_48MHz(void)
{
ErrStatus ClockStatus;
/* Reset CKCU, SYSCLK = HSI */
CKCU_DeInit();
/* Enable HSE */
CKCU_HSECmd(ENABLE);
/* Wait until HSE is ready or time-out */
ClockStatus = CKCU_WaitHSEReady();
if(ClockStatus == SUCCESS)
{
/* PLL configuration, PLLCLK = 48 MHz */
PLLInit.ClockSource = CKCU_PLLSRC_HSE;
#if defined(HTCFG_HSE_12MHZ)
PLLInit.CFG = CKCU_PLL_12M_48M;
#else
PLLInit.CFG = CKCU_PLL_8M_48M;
#endif
PLLInit.BYPASSCmd = DISABLE;
CKCU_PLLInit(&PLLInit);
CKCU_PLLCmd(ENABLE);
/* Wait until PLL is ready */
while(CKCU_GetClockReadyStatus(CKCU_FLAG_PLLRDY) == RESET);
/* FLASH wait state configuration */
FLASH_SetWaitState(FLASH_WAITSTATE_1); /* FLASH one wait clock */
/* HCLK = SYSCLK/1 */
CKCU_SetHCLKPrescaler(CKCU_SYSCLK_DIV1);
/* Configure PLL as system clock */
ClockStatus = CKCU_SysClockConfig(CKCU_SW_PLL);
if(ClockStatus != SUCCESS)
{
while(1);
}
}
else
{
/* HSE is failed. User can handle this situation here. */
while(1);
}
}
|
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。 本文链接:https://blog.csdn.net/weixin_51915497/article/details/123031135 ———————————————— 版权声明:本文为CSDN博主「点灯的棉羊」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/weixin_51915497/article/details/123031135