//时钟32MHz void TIM1_Configuration(void) { TIM1_TimeBaseInitTypeDef TIM1_BaseInitStructure; //TIM1基本计数器设置(设置PWM频率) //频率=TIM1_CLK/(ARR+1) TIM1_BaseInitStructure.TIM1_Period = 3200;//自动重装载寄存器周期的值(定时时间) 累计 0xFFFF个频率后产生个更新或者中断(也是说定时时间到) TIM1_BaseInitStructure.TIM1_Prescaler = 10000-1;//ARR TIM1_BaseInitStructure.TIM1_ClockDivision = 0; TIM1_BaseInitStructure.TIM1_CounterMode = TIM1_CounterMode_Up; TIM1_BaseInitStructure.TIM1_RepetitionCounter = 0; TIM1_TimeBaseInit(&TIM1_BaseInitStructure); TIM1_ClearITPendingBit(TIM1_FLAG_Update); TIM1_ITConfig(TIM1_IT_Update,ENABLE); TIM1_Cmd(ENABLE); }