embassy
embassy copied to clipboard
STM32 SimplePwm: Fix regression and re-enable output pin
PR #2499 implemented timer hierarchy, but removed enable_outputs() from trait CaptureCompare16bitInstance and from SimplePwm.
This functions is required for advanced timers to set bit BDTR.MOE and to enable the output signal.
I left comments in Issue #2409 with my understanding what happened. It's still unclear to me, whether this approach fits the new timer hierarchy.
Since this is the second time, that enable_outputs() got removed from SimplePwm, I added a lengthy comment. I hope, this is ok.
I left comments in Issue #2409 with my understanding what happened. It's still unclear to me, whether this approach fits the new timer hierarchy.
Ah, I'm terribly sorry for this mess. I didn't notice that SimplePwm is implemented on TIM_GP16 at that time, thus adding enable_output() to TIM_1CH_CMP is useless for this situation.
You approach is correct on both old and new timer hierarchy. It requires a empty implement enable_output for TIM_GP16, and enable MOE inside the method for TIM_1CH_CMP / TIM_2CH_CMP / TIM_ADV.
Thanks for your fast response and don't worry about the mess. It's easy to miss the output enable behavior between basic and advanced timers and I only noticed, because I use it in my project.
I can squash the commits, if you agree to the current state.
I can squash the commits, if you agree to the current state.
Yeah! It looks good to me!
And I also test PWM output on my dev board with TIM1(ADV), TIM15(2CH_CMP), TIM16(1CH_CMP), they all output correct waveform.
Thanks. I squashed the commits.