我想用定时器2定时一个1s的中断,但是定时器2的中断在间隔很短的时间就进中断了,想问广大网友,是否配置错误,还是其他问题
void Time2_init()
{
timer_parameter_struct timer_initpara;
rcu_periph_clock_enable(RCU_TIMER2);
timer_deinit(TIMER2);
/* TIMER0 configuration */
timer_initpara.prescaler = 7199;//72M7200分频10khz
timer_initpara.alignedmode = TIMER_COUNTER_EDGE;
timer_initpara.counterdirection = TIMER_COUNTER_UP;//向上计数
timer_initpara.period = 9999;//1s定时
timer_initpara.clockdivision = 0;//不分频
timer_initpara.repetitioncounter = 0;//计数重复值0
timer_init(TIMER2,&timer_initpara);
timer_interrupt_enable(TIMER2,TIMER_INT_UP );
nvic_irq_enable(TIMER2_IRQn,0U);//使能更新中断
timer_auto_reload_shadow_enable(TIMER2);
timer_enable(TIMER2);
}
void TIMER2_IRQHandler(void)
{
if(RESET != timer_interrupt_flag_get (TIMER2,TIMER_INT_FLAG_UP ))
{
time++;
if(time==1)
{
gpio_bit_reset(GPIOA,GPIO_PIN_11);//RST_H
}
else if(time==2)
{
gpio_bit_set(GPIOA,GPIO_PIN_11);//RST_H
time=0;
}
}
timer_interrupt_flag_get(TIMER2,TIMER_INT_FLAG_UP);
} |