How to access functionality of nrfx_pwm.c in nRF Connect SDK

Hi,

We are porting some of our old firmware from SDKs <= 17x to nRF Connect SDK.

We have not found a way to access several of the drivers, like pwm_nrfx.c and use functionality that is not directly available on the Zephyr API.

Specifically I am talking about the ability to define sequences and play them with nrfx_pwm_complex_playback(), including the capability to be notified of the generated events.

Can you point me in the right direction, or even better, show me some sample code that I can compile on v2.0.0?

 

Thanks! Nerd

  • Hi,

    I haven't tried this in v2.0.0 yet, but this has been simple to do in earlier ncs versions. I'll try to implement this on v2.0.0 and get back to you.

    In the meantime, take a look at the application Jared attached here for some pointers: https://devzone.nordicsemi.com/f/nordic-q-a/78591/frequency-not-read-for-nrfx-pwm-peripheral-in-waveform-mode/325867#325867

  • Thank you Offline .

    I tried the sample app in the thread and it has several issues, but I made it work partially.

    For starters, you need to declare CONFIG_PWM for it to build.

    Also, the reason that they say that countertop does not work, is because nrfx_pwm_init() is doing nothing. You can take it away and it still works. The pins selected will be the ones declared by the pinctrl in the dts of the board. That is the reason why led1 lights, since it is the default for pwm0.

    Furthermore, the frequency detected is 1000 Hz. I do not know why.

    The way to declare which pin you want to use is with an overlay, overriding pwm0, and adding pins. I got up to four pins working.

    nrfx_pwm_simple_playback() does work, as well as the seq_values. Taking into account that the top value is 1000, if you place in any of the values of the array to 500, it will give you a perfect 50% duty, in the pin selected.
    There seems to be a collision of the available functions at nrf_pwm.c and the standard init with CONFIG_PWM, as well as calls to pwm_nrfx_init() in zhephyr.lst, which tells me that the module init function is being used.
    I appreciate if you can clarify all this.
    Thanks!
Related