初始化
uint16_t tim1_irq_com_flg=0;
void tim1_init(void)
{
//1分频,向上计数,每50us定时中断一次, 重复计数器值为0
TIM1_TimeBaseInit(0,TIM1_COUNTERMODE_UP,800,0);
TIM1_ARRPreloadConfig(ENABLE);
TIM1_ITConfig(TIM1_IT_UPDATE , ENABLE);
TIM1_Cmd(ENABLE);
}
中断处理
INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
tim1_irq_com_flg++;
TIMER1_Decrement();
TIM1_ClearITPendingBit(TIM1_IT_UPDATE);
}
网友评论