PWM: Single-phase initialization creates flicker #15121
Labels
Area: drivers
Area: Device drivers
Type: bug
The issue reports a bug / The PR fixes a bug (including spelling errors)
Description
The current initialization sequence for PWM is:
pwm_init()
, which sets all values to 0pwm_set()
In active-low situations, this creates flickering between the init and the set.
Steps to reproduce the issue
Check out #15115 and run the saul example on an nrf52840 (whose LEDs are wired active-low). In a brief instant, all LEDs are on before going to their natural (per saul_pwm autoinitialization that sets LEDs dark) state.
Roadmap
The API addition I propose to solve this is simple: Introduce
pwm_init_poweroff()
(pwm_init2
?pwm_init_off
?) that does the same as init but leaves the device in its poweroff mode. Then, the application can set its initial state, and finallypwm_poweron()
to make it actually run.I hope to do this without introducing a feature that's actually a bug-workaround and will never ever go away again. Thus my initial PR will, unless someone comes up with a better option,
pwm_init_poweroff
function with a documentation comment flagging it as experimental.pwm_init()
withpwm_init_poweroff(); pwm_poweron()
to reduce code duplication.I'd then issue a call for platform maintainers to follow the changes.
If the new function is not implemented everywhere after a release cycle, we can still put it behind a feature and remove the experimental label; otherwise, the experimental can go when the last platform is merged.
The text was updated successfully, but these errors were encountered: