void TIM1_Configuration ( void ) { TIM_TimeBaseInitTypeDef TIM_Time1BaseStructure; TIM_OCInitTypeDef TIM_OCInitStructure; RCC_APB2PeriphClockCmd (RCC_APB2Periph_TIM1, the ENABLE); / * Time base timer set * / TIM_Time1BaseStructure.TIM_Prescaler = 0 ; TIM_Time1BaseStructure.TIM_CounterMode = TIM_CounterMode_Up; / * Time setting rising timing of the calculation mode * / TIM_Time1BaseStructure.TIM_Period = (SystemCoreClock / 40000 ) - . 1 ; TIM_Time1BaseStructure.TIM_ClockDivision = 0 ; TIM_Time1BaseStructure.TIM_RepetitionCounter = 0 ; TIM_TimeBaseInit (TIM1, & TIM_Time1BaseStructure); / * Channel 1,2,3,4 PWM mode * / TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; // TIM_OutputState_Enable; // PWM output enable bit TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable; // TIM_OutputNState_Enable; // complementary PWM output enable bit TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low; // PWM active level. 1 = TIM_OCNPolarity_High TIM_OCInitStructure.TIM_OCNPolarity; // the PWM complementary to the active level 0 TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set; TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCIdleState_Reset; TIM_OCInitStructure.TIM_Pulse = 600 - . 1 ; // assigned duty value TIM_OC2Init (TIM1, & TIM_OCInitStructure); // channel 2 can be arranged so that / * TIM1 calculator enable * / TIM_Cmd (TIM1, the DISABLE); / * TIM1 main output enable * / TIM_CtrlPWMOutputs (TIM1, the DISABLE);