This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Using 12 hardware and 1 software channel for pwm on nrf52

Hello I am new to work on nrf52,

Please can someone help me regarding how to use hardware and software pwm together. I have a need of using 13 leds , so i need 13 pwm. As max h/w pwm is 12 so i plan to use 12 h/w pwm using pwm driver, and 1 s/w pwm using pwm library.

When i merge the code from the examples, i copied the code from pwm library to pwm driver and added respective files like  app_pwm.h    app_pwm.c    nrf_drv_ppi.c    nrf_drv_timer.c

to the driver, but it still gives an error that .-- #20: identifier "TIMER0_ENABLED" is undefined ----

Also when i try to do the converse, by adding code from pwm driver to pwm library, it gives error

cannot open source input file "nrf_drv_pwm.h": No such file or directory

Even though i added "nrf_drv_pwm.h" from the components folder of sdk 12.2 on nrf52.

  • You have to enable TIMER0 in sdk_config.h

  • But TIMER0 is not visible in sdk_config.h why is it like that? thanks

  • You can manually edit sdk_config.h or just take it from another example project. I think there is ble_template project somewhere in SDK (or it is in SDK13? worth checking) that contains all the defines needed.

  • thanks the error is gone when i have replaced sdk_config file and enabled timer0 while copying nrf library to nrf driver, but in the output, i am getting the hardware pwm but not the software pwm.

    Please have a look at my code------------------------------------------------------------

  • Please, edit comment and enclose the code in the code tag (101010 icon). Or better, put it as attachement.

1 2