像这样设置可以吗
CLK_PeripheralClockConfig(CLK_Peripheral_TIM2,ENABLE);
/* TIM2 Channel1 configuration: PB0 */
GPIO_Init(GPIOB, GPIO_Pin_0, GPIO_Mode_Out_PP_Low_Fast);
/* Time Base configuration */
TIM2_DeInit();
TIM2_TimeBaseInit(TIM2_Prescaler_1, TIM2_CounterMode_Up, TIM2_PERIOD);
/* Channel 1 configuration in PWM1 mode */
/* 初始占空比为1%*/
TIM2_OC1Init(TIM2_OCMode_PWM1, TIM2_OutputState_Enable, 0, TIM2_OCPolarity_High, TIM2_OCIdleState_Reset);
PWM_TIM2_SetDutyCycle(1);
TIM2_ITConfig(TIM2_IT_Update , ENABLE);
TIM2_ARRPreloadConfig(DISABLE);
/* TIM2 Main Output Enable */
TIM2_CtrlPWMOutputs(ENABLE);
/* TIM2 counter enable */
TIM2_Cmd(ENABLE);
enableInterrupts();
|