使用STM32产生一个占空比3/7,周期为70ms的PWM脉冲,可是当占空比比较小时,输出正常,而改成3/7时却显示如下波形,请大家给予指导,谢谢!
定时器的代码设置如下:
void TIM_Configuration()
{
TIM_DeInit( TIM3);//复位TIM3定时器
TIM_TimeBaseInitStructure.TIM_Period=6999;
TIM_TimeBaseInitStructure.TIM_Prescaler=719; //
TIM_TimeBaseInitStructure.TIM_ClockDivision=TIM_CKD_DIV1;
TIM_TimeBaseInitStructure.TIM_CounterMode=TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM3,&TIM_TimeBaseInitStructure);
TIM_OCInitStructure.TIM_OCMode=TIM_OCMode_PWM1;
//TIM_OCInitStructure.TIM_Channel=TIM_Channel_3;
TIM_OCInitStructure.TIM_Pulse = 2999;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OCInitStructure.TIM_OutputState=TIM_OutputState_Enable;
TIM_OC3Init(TIM3, &TIM_OCInitStructure);
TIM_CtrlPWMOutputs(TIM3,ENABLE);
TIM_Cmd(TIM3,ENABLE);
}
|