/* 定时器配置:
1.设置定时器最大计数值 50000
2.设置时钟分频系数:TIM_CKD_DIV1
3. 设置预分频: 1Mhz/50000= 1hz
4.定时器计数模式 向上计数模式
*/
TIM_TimeBaseStructure.TIM_Period = 0xffff;
TIM_TimeBaseStructure.TIM_Prescaler = 72; //1M 的时钟
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
//应用配置到TIM3
TIM_TimeBaseInit(TIM3, &TIM;_TimeBaseStructure);
// 使能TIM3重载寄存器ARR
TIM_ARRPreloadConfig(TIM3, ENABLE);
1