Potential bug on PWM driver when set with 100% pulse

  • Hi,

while developing a custom driver for the nRF54L15, using the PWM I have found a potential bug.

I have removed the custom driver and just enabled PWM shell and I can reproduce the bug typing this commands:

Here the debug watch data of the pwm_nrfx_0_data structure during the test.

Boot:

After: pwm nsec pwmd2000 0 50000 0:

(I would aspect the pwriod_cycles t be equal to 800).

After: pwm nsec pwmd2000 1 50000 0:

After: pwm nsec pwmd2000 1 50000 50000:

After pwm nsec pwmd2000 1 50000 100:

I hade basically this sequence of commands in my custom driver that is why I have found this issue.

I believe the period_cycles of the driver instance is not properly set when pwm is configured with 100% pulse...

We are on ncs 3.2.4 

Thanks,


andrea

Parents Reply
  • Hi again andrea,

    I successfully reproduced this with both v3.2.4 and v3.3.0 and I dove deeper into the code to find the reason for this error happening. What I found was that with the default Kconfig symbols, this is the intended behaviour to not get glitches when using 100% duty cycle for one PWM channel at the same time as driving other channels. Setting 100% duty cycle for several PWM channels is an exception for this rule.

    So, what the driver does is to set the needs_pwm flag when requesting 100% duty cycle. On subsequent requests to set non-100% duty cycles for another channel, the flag is still set, which translates to pwm_needed reflecting the channel which currently is at 100% duty cycle. 

    You can disable this behaviour by setting CONFIG_PWM_NRFX_NO_GLITCH_DUTY_100=n in your prj.conf. Note that you should only do so if you can handle potential glitches.

    Best regards,

    Maria 

Children
No Data
Related