2 PWM channels with Phase Offset #nrf52832 #pwm


Hello Zephyr community,

I'm working on an nrf52832 based project with Zephyr and am looking to implement two PWM channels with variable phase-offset. As far as I can tell, the nrfx drivers don't expose any sort of phase control explicitly nor does Zephyr's PWM library. Some options I've found directly within the nordic environment are using PPI or using the sequence_values table:


One key requirement for me is that the phase offset is not fixed - i.e. i want to be able to sweep both PWM channel frequencies and adjust the phase offset of the second channel on the fly, with the goal of a waveform that looks approximately like this:

Period: 333us
PWM0 sequence: On for 100us, off for 233us
PWM1 sequence: Off for 100us, on for 100us, off for 133us

Crude text based representation (that might not display well on all environments) below of 2 periods of this signal:

PWM0 |  |____|  |____
PWM1 __|  |____|  |__

Is there a clean way to do this? I'm thinking the PPI triggered start of PWM1 for the phase offset, but if there is a way to do this without engaging the lower level nordic libraries that would be ideal.

Thank you,