2020-09-15 10:16 AM
I configured timer1 for pwm generation center aligned like below in cube ide.
I update duty cycle writing directly CCRx register asyncronously in the code.
Most of the time pulses are effectively center aligned but sometimes not (nor left or right aligned). Please, a suggestion.
Raffaele
2020-09-15 11:03 AM
When you update CCRx, the value may take effect immediately, in which case you shouldn't expect a center-aligned pulse. You'll need to update it during the idle portion of the pulse.
You can enable preload, but the change will take effect on both the overflow and underflow event, which isn't what you want.
2020-09-15 11:55 AM
> You can enable preload, but the change will take effect on both the overflow and underflow event, which isn't what you want.
This is why updating CCRx in center-aligned mode is tricky and you may want to use the interrupt from one of the Compare channels (maybe even an unused one) set to a suitable level (maybe close to or at some of the endpoints) and maybe use one of the "CC interrupts only in one direction" modes in CMS.
(I don't understand ST's design decision in this particular issue - they might've have 3 behaviours in respect to Update Event as well).
JW