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

SDK 15.2 SAADC functions undefined?

Hi all,

I currently need to implement 3 channels of analog inputs on my nrf52, but when I attempt to compile the project, I get the following errors:

undefined reference to `nrfx_saadc_buffer_convert'

undefined reference to `nrfx_saadc_init'

undefined reference to `nrfx_saadc_channel_init'

undefined reference to `nrfx_saadc_sample'

I used the following example as a reference when setting everything up: https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/saadc_5F00_simpler.zip

I'm not sure why it can't find the references when I have all of the necessary header files. I also enabled the SAADC in the sdk_config.h file.

Any thoughts?

Parents
  • It looks like the main problem is the functions in the nrf_drv_saadc.h file can't locate the definitions from nrfx_saadc.h. This makes no sense to me as they are clearly defined and I have t nrfx_saadc.h, nrfx_saadc.c, and nrf_drv_saadc.h in the same folder as main.c and have added them into the Application folder.

  • Found the problem. in sdk_config.h, setting NRFX_SAADC_ENABLED to 1 does nothing unless you also set SAADC_ENABLED to 1 as they are linked in apply_old_config.h.

  • I am having the same problem, but setting both NRFX_SAADC_ENABLED and SAADC_ENABLED has not helped me.

    Error:

    _build/nrf52832_xxaa/battery.c.o: In function `nrf_drv_saadc_init':
    c:\Users\Michael\Documents\rStrap\nRF5_SDK_15.2.0_9412b96\examples\ble_peripheral\ble_app_hts\pca10040\s132\armgcc/../../../../../../integration/nrfx/legacy/nrf_drv_saadc.h:134: undefined reference to `nrfx_saadc_init'
    collect2.exe: error: ld returned 1 exit status
    make: *** [_build/nrf52832_xxaa.out] Error 1
    make: Leaving directory `c:/Users/Michael/Documents/rStrap/nRF5_SDK_15.2.0_9412b96/examples/ble_peripheral/ble_app_hts/pca10040/s132/armgcc'

    battery.c function:

    #include "battery.h"
    #include "nrf_drv_saadc.h"
    #include "app_error.h"
    #include "nrf_log.h"
    
    uint8_t ReadBatteryLevel()
    {
        return 0;
    }
    
    #define ADC_REF_VOLTAGE_IN_MILLIVOLTS  600  //!< Reference voltage (in milli volts) used by ADC while doing conversion.
    #define DIODE_FWD_VOLT_DROP_MILLIVOLTS 270  //!< Typical forward voltage drop of the diode (Part no: SD103ATW-7-F) that is connected in series with the voltage supply. This is the voltage drop when the forward current is 1mA. Source: Data sheet of 'SURFACE MOUNT SCHOTTKY BARRIER DIODE ARRAY' available at www.diodes.com.
    #define ADC_RES_10BIT                  1024 //!< Maximum digital value for 10-bit ADC conversion.
    #define ADC_PRE_SCALING_COMPENSATION   6    //!< The ADC is configured to use VDD with 1/3 prescaling as input. And hence the result of conversion is to be multiplied by 3 to get the actual value of the battery voltage.
    #define ADC_RESULT_IN_MILLI_VOLTS(ADC_VALUE) \
       ((((ADC_VALUE) *ADC_REF_VOLTAGE_IN_MILLIVOLTS) / ADC_RES_10BIT) * ADC_PRE_SCALING_COMPENSATION)
    
    static void saadc_event_handler(nrf_drv_saadc_evt_t const * p_evt) {}
    
    void BatteryADCInit(void)
    {
        ret_code_t err_code;
        err_code = nrf_drv_saadc_init(NULL, saadc_event_handler);
        APP_ERROR_CHECK(err_code);
    }

    SDK Config:

    // <e> NRFX_SAADC_ENABLED - nrfx_saadc - SAADC peripheral driver
    //==========================================================
    #ifndef NRFX_SAADC_ENABLED
    #define NRFX_SAADC_ENABLED 1
    #endif
    // <o> NRFX_SAADC_CONFIG_RESOLUTION  - Resolution
    
    // <e> SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver - legacy layer
    //==========================================================
    #ifndef SAADC_ENABLED
    #define SAADC_ENABLED 1
    #endif
    // <o> SAADC_CONFIG_RESOLUTION  - Resolution

  • Never mind. I was missing an include in my MakeFile

    # Source files common to all targets
    SRC_FILES += \
      $(PROJ_DIR)/Src/battery.c \
      $(PROJ_DIR)/Src/tension.c \
      $(PROJ_DIR)/Src/temperature.c \
      $(SDK_ROOT)/components/ble/ble_services/ble_nus/ble_nus.c \
      $(SDK_ROOT)/components/ble/ble_link_ctx_manager/ble_link_ctx_manager.c \
      $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_saadc.c \ --------Was missing this

Reply Children
No Data
Related