自己找到了个参考例程
static void TIM2_Config(void)
{
/* Enable TIM2 clock */
CLK_PeripheralClockConfig(CLK_Peripheral_TIM2, ENABLE);
/* DeInit TIM2 */
TIM2_DeInit();
/* TIM2 Time base configuration */
TIM2_TimeBaseInit(TIM2_Prescaler_1, TIM2_CounterMode_Up, 0xFFFF);
/* TIM2 channel 1 configuration */
TIM2_OC1Init(TIM2_OCMode_PWM1, TIM2_OutputState_Enable, 0x7FFF, TIM2_OCPolarity_High, TIM2_OCIdleState_Reset);
/* TIM2 Counter Enable */
TIM2_Cmd(ENABLE);
TIM2_CtrlPWMOutputs(ENABLE);
}
|