大家好,我现在用使用的是STM32F103VET6,利用TIM1,想实现每667us进一次TIM1_UP_IRQn中断,在中断里去做一些事情。配置如下(NVIC已配置好,主频72M):
TIM_DeInit(TIM1);
TIM_TimeBaseStructure.TIM_Period = 0x2580;
TIM_TimeBaseStructure.TIM_Prescaler = 4;
TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure);
TIM_ITConfig(TIM1,TIM_IT_Update, ENABLE);
TIM_Cmd(TIM1, ENABLE);
但调试时发现,执行到TIM_ITConfig(TIM1,TIM_IT_Update, ENABLE)后,就会进TIM1_UP_IRQHandler(void),然后执行TIM_Cmd(TIM1, ENABLE);
不是还没开始计数吗,怎么会先进中断呢? |