定时器周期计算公式
例如:
TIM_TimeBaseStructure.TIM_Period = 10000-1; //当定时器从0计数到10000,即为10000次,为一个定时周期10khz TIM_TimeBaseStructure.TIM_Prescaler = 71; //设置预分频:1us/clk TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1 ; //设置时钟分频系数:不分频(是对外部时钟TIMXETR进行滤波的) TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //向上计数模式 TIM_TimeBaseStructure.TIM_RepetitionCounter=0; //不使用重复计数 TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
Tout=(10000)*(71+1)/72M=10MS