PWM under Zephyr seems to change the state of the other channels on the PWM devices

PWM usage under Zephyr seems to be a little odd, quite likely because using a PWM channel changes the state of the other channels on the PWM devices.

I can reproduce the issue easily under nRF52840, nRF52833 (Microbit v2) and STM32.

For example, if I have two LEDs connected to PWM1 channels 0 & 1, and the third LED to another PWM2 channel 0, driving one of the PWM, say PWM1 0 works fine, as expected. However, the other two LEDs on the PWM1 channel 1 & PWM2 channel 0 will also light up. One way around it, at least on the PWM not driving the PWM signal, is to explicitly set the other LED LOW and somehow also turn off the PWM1 channel 1 LED.

If I use the same code with the Arduino Core, the problem doesn’t arise. Arduino appears to clear the previous PWM states on initialization. I think with Zephyr, the user has to reset the previous state of the PWMs before use.

Has anyone else seen the above or similar behavior? I can share more info if needed.

What’s the best way to make sure that any previous PWM states have been cleared before use? Thanks.

Does anyone have any feedback on the above issue to share? Thanks.