比如别的程序里面会有以下代码设置时钟和分频
ErrorStatus HSEStartUpStatus; RCC_DeInit(); /* RCC system reset(for debug purpose)/ RCC_HSEConfig(RCC_HSE_ON); / Enable HSE/ HSEStartUpStatus = RCC_WaitForHSEStartUp(); / Wait till HSE is ready */
if(HSEStartUpStatus == SUCCESS) { FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); /* Enable Prefetch Buffer */ FLASH_SetLatency(FLASH_Latency_2); /* Flash 2 wait state */ RCC_HCLKConfig(RCC_SYSCLK_Div1); /* HCLK = SYSCLK */ RCC_PCLK2Config(RCC_HCLK_Div1); RCC_PCLK1Config(RCC_HCLK_Div1); /* PCLK2 = HCLK */ // RCC_PCLK1Config(RCC_HCLK_Div2); /* PCLK1 = HCLK/2 */ //注:AHB主要负责外部存储器时钟。APB2负责AD,I/O,高级TIM,串口1 // APB1负责DA,USB,SPI,I2C,CAN,串口2345,普通TIM RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_6); /* PLLCLK = 12MHz * 6 = 72 MHz */ RCC_PLLCmd(ENABLE); /* Enable PLL */ while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) /* Wait till PLL is ready */ { } RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); /* Select PLL as system clock source */ while(RCC_GetSYSCLKSource() != 0