Adding PWM Channels in Zephyr

I am developing a custom board application in Zephyr 3.2.99.  I have a single PWM Channel running now but having trouble adding addtional channels.

In the 52811.dtsi, I have a single pwm node:

then, in my pinctrl-dtsi I have:

The in my .dts I have:

and:

in my main driver, I have followed the Zephyr example code:

I have been stuck on this for a while and now I'm really in a bind.

Thanks,

Drew

Parents
  • Hi Drew

    I think the problem is that you haven't properly added the additional channels to the pinctrl and pwmleds nodes. 

    I was able to add a second channel to the led_pwm sample in Zephyr simply by adding the following overlay file to the example:

    Please note I used a nRF52840DK for the test, but the code should look similar for the nRF52811. 

    Best regards
    Torbjørn

  • Thanks for the reply. I figured that out shortly after I posted. The problem was that I had the pwmleds configured as the default PWM_POLARITY_INVERTED. So the led's would turn on as soon as the board started.  I switched to PWM_POLARITY_NORMAL and now everything is behaving as we desire.

    I simply commented out the "nordic,invert" property in the pinctrl-dtsi but I'm not sure if that is the proper way to handle that.

    Drew

  • Hi Drew

    Yes, you can just remove this property from the overlay. 

    In the long run you might want to create your own custom board implementation rather than using an overlay, then you can set this properly in the board files directly. 

    Best regards
    Torbjørn

  • That is very helpful. We don't use overlays. All of our Zephyr implementions use custom BSP.  You may consider this issue closed.  Thank you all for your support.

  • Glad I could help Drew. The best of luck with your project Slight smile

Reply Children
No Data