void RCC_Configuration(void)
{
// SystemInit();
ErrorStatus HSEStartUpStatus = SUCCESS;
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 = 8M
RCC_PCLK2Config(RCC_HCLK_Div1); //PCLK2(3-5M) = HCLK/1 = 4M
RCC_PCLK1Config(RCC_HCLK_Div2); //PCLK1(3-12M) = HCLK/2 = 8M
RCC_ADCCLKConfig(RCC_PCLK2_Div2); //ADCCLK = PCLK2/2 = 2M
RCC_PLLConfig(RCC_PLLSource_HSI_Div2, RCC_PLLMul_8);
RCC_PLLCmd(ENABLE); //Enable PLL (18-72M)
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() != 0x08); //Wait till PLL is used as system clock source
}
else{ while (1); }
////////////////////////////////////////////////////////////////////////////////
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
RCC_APB1PeriphClockCmd( RCC_APB1Periph_USART2 |RCC_APB1Periph_USART3 |
RCC_APB1Periph_USART3 |RCC_APB1Periph_UART4 |
RCC_APB1Periph_UART5 |RCC_APB1Periph_TIM2 , ENABLE);
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA |RCC_APB2Periph_GPIOB |
RCC_APB2Periph_GPIOC |RCC_APB2Periph_GPIOD |
RCC_APB2Periph_GPIOE |RCC_APB2Periph_GPIOF |
RCC_APB2Periph_USART1 |RCC_APB2Periph_ADC1 |
RCC_APB2Periph_TIM1 |RCC_APB2Periph_AFIO ,ENABLE);
}
使用的是3.3的库 预定义的是。。。。。_CL
改成使用外部晶振8M老是不对,上面的程序是内部8M定时器和波特率多对,
麻烦改成使用外部晶振8M主频72M 波特率设置正确 |