首页 > 代码库 > STM32 高速定时器配置为PWM使用细节

STM32 高速定时器配置为PWM使用细节

//初始化TIM8 Channel1 PWM?模式
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2; //
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; //
//TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; //
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low; //
TIM_OC3Init(TIM8, &TIM_OCInitStructure); //

TIM_OC3PreloadConfig(TIM8, TIM_OCPreload_Enable); //

TIM_Cmd(TIM8, ENABLE); //
TIM_CtrlPWMOutputs(TIM8, ENABLE); // 设置TIM8的PWM输出为使能 TIM1和TIM8定时器需要加上这句

STM32 高速定时器配置为PWM使用细节