在线时间0 小时
UID278167
ST金币0
蝴蝶豆0
注册时间2011-4-12
新手上路
- 最后登录
- 1970-1-1
|
a0a.1 0b0c
用一个TIM发相位相差180度、占空比小于50%的两路PWM用于驱动推挽变换器,但是每次复位之后都会有一个脉冲,不知道是怎么来的。如图
这个是软启动时的
还有启动时没有开TIM时的波形
我的配置如下
void TIM4_Configuration(void)
{
TIM_TimeBaseInitTypeDef TIM_TBInitStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
uint16_t PrescalerValue = 0;
PrescalerValue = (uint16_t) (SystemCoreClock / 24000000) - 1;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);
TIM_TBInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TBInitStructure.TIM_CounterMode = TIM_CounterMode_CenterAligned1;
TIM_TBInitStructure.TIM_Period = 1200; //10kHz Equal to 20kHz for push-pull
TIM_TBInitStructure.TIM_Prescaler = PrescalerValue;
TIM_TBInitStructure.TIM_RepetitionCounter = 1;
TIM_TimeBaseInit(TIM4, &TIM_TBInitStructure);
TIM_PrescalerConfig(TIM4, PrescalerValue, TIM_PSCReloadMode_Immediate);
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Reset;
TIM_OCInitStructure.TIM_Pulse = 60;
TIM_OC3Init(TIM4, &TIM_OCInitStructure);
TIM_OC3PreloadConfig(TIM4, TIM_OCPreload_Enable);
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Reset;
TIM_OCInitStructure.TIM_Pulse = 1140;
TIM_OC4Init(TIM4, &TIM_OCInitStructure);
TIM_OC4PreloadConfig(TIM4, TIM_OCPreload_Enable);
TIM_ARRPreloadConfig(TIM4, ENABLE);
TIM_SetCounter(TIM4, 600);
TIM_ClearFlag(TIM4, TIM_FLAG_CC3| TIM_FLAG_CC4);
TIM_ITConfig(TIM4, TIM_IT_CC4, ENABLE);
TIM_Cmd(TIM4, ENABLE);
}
是配置有问题么?怎么才能解决呢?谢谢各位啦!
|
|