embassy icon indicating copy to clipboard operation
embassy copied to clipboard

STM32 SimplePwm: Fix regression and re-enable output pin

Open jr-oss opened this issue 1 year ago • 2 comments

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.

jr-oss avatar Mar 07 '24 18:03 jr-oss

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.

jr-oss avatar Mar 07 '24 19:03 jr-oss

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.

eZioPan avatar Mar 08 '24 01:03 eZioPan

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.

jr-oss avatar Mar 08 '24 09:03 jr-oss

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.

eZioPan avatar Mar 08 '24 10:03 eZioPan

Thanks. I squashed the commits.

jr-oss avatar Mar 08 '24 10:03 jr-oss