在没有使用 TIM_Cmd(TIM2, ENABLE); 使能定时器的时候,stm32会进一次中断吗? 打印如下: _____MY_TIMERINIT _____TIM2_IRQHandler 代码如下://这是定时器初始化的函数 void MY_TIMERINIT(int arr,int psc) { TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStruct; NVIC_InitTypeDef NVIC_InitStruct; printf("\r\n_____%s\r\n",__func__); RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,ENABLE); TIM_TimeBaseInitStruct.TIM_ClockDivision = TIM_CKD_DIV1; TIM_TimeBaseInitStruct.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInitStruct.TIM_Period = arr; TIM_TimeBaseInitStruct.TIM_Prescaler = psc; TIM_TimeBaseInit( TIM2, &TIM_TimeBaseInitStruct); TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE); NVIC_InitStruct.NVIC_IRQChannel = TIM2_IRQn; NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE; NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 1 ; NVIC_InitStruct.NVIC_IRQChannelSubPriority = 1; NVIC_Init(&NVIC_InitStruct); } //这是定时器中断的函数 void TIM2_IRQHandler(void) { printf("\r\n_____%s\r\n",__func__); if(TIM_GetITStatus(TIM2, TIM_IT_Update)!=RESET) { } } |
TIM_ClearITPendingBit(TIM1, TIM_IT_Update); //清除更新中断请求位
TIM_ITConfig(TIM1, TIM_IT_Update, ENABLE); //使能定时器1更新中断
TIM_Cmd(TIM1, ENABLE); //启动定时器
http://mp.weixin.qq.com/s?__biz=MzA3OTIxMjQyNQ==&mid=205748433&idx=1&sn=e86e3a12d93d702878657eeb2d655020#rd