Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

PWM setup on the NRF52DK

Hello all,

Four leds are connected to the GPIO (22-25) and gpio are defined and with a simple method within the while loop I can see them working

    nrf_gpio_pin_write(GPIO_PIN_22, 1);
    nrf_gpio_pin_write(GPIO_PIN_23, 1);
    nrf_gpio_pin_write(GPIO_PIN_24, 1);
    nrf_gpio_pin_write(GPIO_PIN_25, 1);

Next is to use the PWM and I am looking at the pwm_driver example that comes with the 17.1.0 SDK examples and in the SDK config.h the PWM setup can be seen and modified, however, when looking into my application, I cannot see the setup configuring in the SDK config.h , with regard to the PWM only the following can be seen :"  // <e> PWM_CONFIG_LOG_ENABLED - Enables logging in the module."

Indeed, I am missing the "nrfx_pwm.c" in the "nRF_Drivers" folder, however, will the "SDK setup" adopt its config, if that file is added?

Anyway, I am not sure where to find the right driver file? Looked at the "legacy" but somehow it is not there, indeed, I am would like to use the onboard PWM hardware, if possible...

Any ideas how to get the files in order and start using the PWM driver?

Any help is much appreciated.

Best.

  • Hi MuRa,

    I have worked on the nrf52 chip, Where the PWM signals can be routed to all the GPIO pins I believe. 

    For adding the PWM support to our project, we have to add those required configurations into our project's  sdk_config.h file as well as to add corresponding files to the project.

    [

    From the project explorer, right-click and select the add existing files, navigate and select the pwm driver, so that we can use the PWM SDK functions into our project.

    nRF5_SDK_17.0.2_d674dde/modules/nrfx/drivers/src/nrfx_pwm.c

  • Hello Jeavan R Raj

    Thank you, I have managed to add the "nrfx_pwm.c" into the nRF_Drivers" folder, so far so good.

    For adding the PWM support to our project, we have to add those required configurations into our project's  sdk_config.h file as well as to add corresponding files to the project.

    If I understood you right, do I have to write that manually into the sdk_config.h?

    For example, although the nrfx_pwm.c is now evident in the drivers' folder, I cannot enable the PWN driver via the CMSIS configuration via the right-click on the Application folder ... I guess I should be able to enable the driver over there or I will have to manually write the setup into the SDK configuration or I do not need to worry about enabling the PWM driver this way, but just to write it into the SDK Config file?

    Best.

  • Hi MuRa,

    If I understood you right, do I have to write that manually into the sdk_config.h?

    Yes, you are right here. We have to add manually into the SDk_config.h file.

    If you check on the nrfx_pwm.c source file you can see like,

    #if NRFX_CHECK(NRFX_PWM_ENABLED)

    All the functions inside the driver file can be used if this macro is enabled in the config.h file like following

    #ifndef NRFX_PWM_ENABLED
    #define NRFX_PWM_ENABLED 1
    #endif

    Similarly,  I  guess there are a few other macros also need to be inside this same config file for the proper working

Related