2022-11-30 12:19 AM
I have a problem with Timer1 PWM generation.
We need to generate three pairs complementary PWM signals. The compare value can be modified at counter overflow and underflow event, as below shows.It seems the PWM center-aligned mode can’t meet the requirement.
It should use the Asymmetric PWM mode, but there are only two pairs complementary PWM signals can be generated in this mode,.
What should I to produce the PWM waveform I want
2022-11-30 12:26 AM
>>three pairs complementary PWM signals
Are you trying to drive a motor or an inverter?
>>It seems the PWM center-aligned mode can’t meet the requirement.
why not?
2022-11-30 04:42 PM
Yes, I want to drive a motor.
As the above pic. shows, we need to change the rising edge and the falling edge through change the compare value at T1 and T2, tests found, the falling edge time wasn't changed, falling edge compare value is same as the rising falling edge,even through the value has been changed at T2 in the pwm center-aligned mode,as the red dash line shows.
2022-12-01 02:18 AM
Hello if I understood correctly u want to change compare value for falling edge of ur pwm , that means you want to have diffrent compare value on your rising edge and falling edge , use an intruppt either when cnt match arr or when cnt match compare1 value and change the ccr value in that intruppt to compare2 and again use another intruppt (when cnt match compare2) to change the ccr to compare1 value.
(p.s. cnt is the counter , Arr is your Auto Reload Register , and ccr is your compare value )
2022-12-01 03:13 AM
maybe you want 2 separate adjustable point in time, you cannot use center aligned mode, because this is doing , what the name suggest: symm. around center.
what could be perfect for you, is combined mode --> read in rm, how to do. Tim1 can do this mode.
but : usually to drive a motor you need only "standard" pwm, + complement. outputs (with deadtime) , x3 for 3-phase motor..
2022-12-12 03:35 AM
>>Yes, I want to drive a motor.
Youyre probably trying to implement FOC current controlled drive.
A lot of people (including me) is already driving motors that way, maybe look at their usage of TIM, it only takes a bit of research to realise youre reinventing the wheeel here.
Center aligned mode should work and its the mode used for this kind of motor control, Both edges should change in center mode PWM generation so im more inclined to believe you messed up somehwere in the PWM config.
2022-12-12 05:17 PM
Hi Javier,
Thanks for your reply. The register configuration is incorrect,the issue is resolved.
compare register preload should be enabled