void TIM3_Configuration(void) { TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; TIM_ClearITPendingBit(TIM3,TIM_IT_Update); TIM_TimeBaseStructure.TIM_Period =1000; TIM_TimeBaseStructure.TIM_Prescaler =0; //72mhz TIM_TimeBaseStructure.TIM_ClockDivision =0; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM3,&TIM_TimeBaseStructure); TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE); TIM_Cmd(TIM3,ENABLE); } 请问如果我这样配置定时器的话,是不是每1/72000秒触发一次中断? 谢谢! |
谢谢,但是我试过900,响应没问题,但是就是不知道是不是会漏掉
谢谢分享参考!
TIM_DeInit(TIM2); //初始化TIM2为缺省值
TIM_TimeBaseInitStruct.TIM_Period = (10 - 1); //配置ARR自动重载寄存器
TIM_TimeBaseInitStruct.TIM_Prescaler = (72 - 1); //配置PSC时钟预分频
TIM_TimeBaseInitStruct.TIM_ClockDivision = TIM_CKD_DIV1; //配置时间分割值
TIM_TimeBaseInitStruct.TIM_CounterMode = 0x0000; //配置计数器向上计算
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseInitStruct); //初始化
TIM_ClearFlag(TIM2, TIM_FLAG_Update); //清除溢出中断标志
TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE); //打开中断溢出
TIM_Cmd(TIM2, ENABLE); //失能TIM2定时器
谢谢回答!