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

nrf_drv_pwm_init error on compile

Hi. Using SDK13, nrf52, and the awful IDE Segger, I keep getting this error no matter what kind of code or project with PWM I use :

Undefined reference to  nrf_drv_pwm_init

I did:

  1. I have added the file nrf_drv_pwm.c
  2. I have added to the preprocessor: ../../../../../../components/drivers_nrf/pwm
  3. I have enabled on the config file : #define PWM_ENABLED 1

Nothing helps, here is the function that causing this ( intrestingly other functions from the driver will NOT CAUSE ERRORS)

#include <stdio.h>
#include <string.h>
#include "nrf_drv_pwm.h"
#include "app_util_platform.h"
#include "app_error.h"
#include "boards.h"
#include "bsp.h"
#include "nrf_drv_clock.h"
#include "nrf_delay.h"


/// MORE STUFF HERE 

static void pwm_init(void)
{
    nrf_drv_pwm_config_t const config0 =
    {
        .output_pins =
        {
            OUTPUT_PIN, // channel 0
            NRF_DRV_PWM_PIN_NOT_USED,             // channel 1
            NRF_DRV_PWM_PIN_NOT_USED,             // channel 2
            NRF_DRV_PWM_PIN_NOT_USED,             // channel 3
        },
        .irq_priority = APP_IRQ_PRIORITY_LOWEST,
        .base_clock   = NRF_PWM_CLK_1MHz,
        .count_mode   = NRF_PWM_MODE_UP,
        .top_value    = 100,
        .load_mode    = NRF_PWM_LOAD_INDIVIDUAL,
        .step_mode    = NRF_PWM_STEP_AUTO
    };
    // ******** ERROR IS ONLY ON THIS CALL , NOT THE PREVIOUS ONE
    APP_ERROR_CHECK(nrf_drv_pwm_init(&m_pwm0, &config0, NULL));   //****ERROR HERE !
 
    
}
Parents
  • For anyone who is interesting, seems that the nrf_drv_pwm.h will not be included if you don't :

    on config file set ALL of these to 1 :

    PWM_ENABLED 
    PWM0_ENABLED 
    PWM1_ENABLED 
    PWM2_ENABLED
    

    What's really amazing me, is why Nordic can't set these values them self? **this is a basic user experience!

    Why do I have to fight for every little thing?

    How hard is to create a class called pwm, that get this

    set_pwm(duty_cycle) 
    

    Thats it !! how hard is it ?

    I always knew that in Norway you are really good with simplicity, but with this company it's too hard for no reason.

  • Maybe somebody will find the following information useful. (Disclaimer: it may not be complete or completely correct, but it works in my case)

    For implementation of nrf_drv_pwm in our app (nRF52832 DK, BT mesh based on light_switch_example, i.e. with softdevice s132) I needed to:

    • #include "nrf_drv_pwm.h" in the .c file where I use PWM
    • add file nrfx_pwm.c to the folder structure of the project
    • include folders to preprocessor:
      • SDK/integration/nrfx/legacy (for nrf_drv_pwm.h)
      • SDK/modules/nrfx/drivers/include (for nrfx_pwm.h)
    • in app_config.h: (I only use PWM1 (0 uses TIMER0 which is used by softdevice)
      • #define PWM_ENABLED 1
      • #define PWM1_ENABLED 1
Reply
  • Maybe somebody will find the following information useful. (Disclaimer: it may not be complete or completely correct, but it works in my case)

    For implementation of nrf_drv_pwm in our app (nRF52832 DK, BT mesh based on light_switch_example, i.e. with softdevice s132) I needed to:

    • #include "nrf_drv_pwm.h" in the .c file where I use PWM
    • add file nrfx_pwm.c to the folder structure of the project
    • include folders to preprocessor:
      • SDK/integration/nrfx/legacy (for nrf_drv_pwm.h)
      • SDK/modules/nrfx/drivers/include (for nrfx_pwm.h)
    • in app_config.h: (I only use PWM1 (0 uses TIMER0 which is used by softdevice)
      • #define PWM_ENABLED 1
      • #define PWM1_ENABLED 1
Children
No Data
Related