STM32F051R8T6的RCC配置
void RCC_Configuration(void)
{
ErrorStatus HSEStartUpStatus;
RCC_DeInit();
RCC_HSEConfig(RCC_HSE_ON); //RCC_HSE_ON--HSE晶振打開(ON)
HSEStartUpStatus = RCC_WaitForHSEStartUp();
if(HSEStartUpStatus == SUCCESS) //SUCCESS:HSE晶振穩(wěn)定且就緒
{
FLASH_SetLatency(FLASH_Latency_1); //FLASH_Latency_1 1延時(shí)周期
FLASH_PrefetchBufferCmd(ENABLE); // 預(yù)取指緩存使能
/* PLL configuration: pllclk= HSE * 6 = 48 MHz */
RCC_PREDIV1Config(RCC_PREDIV1_Div1);
RCC_PLLConfig(RCC_PLLSource_PREDIV1, RCC_PLLMul_6);
RCC_HCLKConfig(RCC_SYSCLK_Div1); //RCC_SYSCLK_Div1--AHB時(shí)鐘 HCLK= SYSCLK(48)系統(tǒng)時(shí)鐘
RCC_PCLKConfig(RCC_HCLK_Div1); //PCLK = HCLK = 48
RCC_PLLCmd(ENABLE);
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET){}
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); //選擇PLL作為sysclk系統(tǒng)時(shí)鐘 SYSCLK = PLLCLK
while(RCC_GetSYSCLKSource() != 0x08){} //等待系統(tǒng)時(shí)鐘設(shè)置成功 0x08:PLL作為系統(tǒng)時(shí)鐘
}
}
評(píng)論