void TIMER2_Config()
{
TIM_TimeBaseStructure.TIM_Period =5000;
TIM_TimeBaseStructure.TIM_Prescaler = (7200-1);
TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE );
TIM_Cmd(TIM2, ENABLE);
}
按照例程里面似乎这个时间应该是500MS,但是我怎么跑出了5S的样子呢~~~而且我用向上和向下模式似乎时间没区别、、、、、、~求指教,那个5000和7200-1就是寄存器里面配置的两参数吧~
void RCC_Config()
{
RCC_DeInit();
HSEStartUpStatus = RCC_WaitForHSEStartUp();
if(HSEStartUpStatus == SUCCESS)
{
RCC_HCLKConfig(RCC_SYSCLK_Div1);
RCC_PCLK1Config(RCC_HCLK_Div2);
RCC_PCLK2Config(RCC_HCLK_Div1);
RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
RCC_PLLCmd(ENABLE);
while( RCC_GetFlagStatus(RCC_FLAG_PLLRDY)==RESET)
{}
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
while(RCC_GetSYSCLKSource() != 0x08)
{}
}
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOD |
RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO , ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2 ,ENABLE);
}
这个是我的RCC的配置~
|