配置定时器3中断以后,延时不起作用
定时器3配置如下:
void TIM3_Conifg(uint8_t num_t)
{
TIM_TimeBaseInitTypeDef TimeBaseInstructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3,ENABLE);
TIM_DeInit(TIM3);
TimeBaseInstructure.TIM_Period = 10*num_t;
TimeBaseInstructure.TIM_Prescaler = 7200;
TimeBaseInstructure.TIM_ClockDivision = 0;
TimeBaseInstructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM3,&TimeBaseInstructure);
TIM_ClearFlag(TIM3,TIM_FLAG_Update);
TIM_Cmd(TIM3,ENABLE);
TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE);
}
定时器3中断代码如下:
void TIM3_IRQHandler(void)
{
if(TIM_GetITStatus(TIM3,TIM_IT_Update) == SET)
{
screen_scan(sc1,sc2,sc3,sc4); delay_ms(5);
TIM_ClearITPendingBit(TIM3,TIM_IT_Update);
}
}
|