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

Linking error with SAADC driver

I am getting the linking error seen in the uploaded image. I am using segger embedded studio with SDK 15.3.0. I have already added the nrfx_saadc.c file to the project folder as well as enabled saadc in the config file.

#define SAMPLES_IN_BUFFER 1
static nrf_saadc_value_t     m_buffer_pool[2][SAMPLES_IN_BUFFER];

void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
{
    if (p_event->type == NRF_DRV_SAADC_EVT_DONE)
    {
        ret_code_t err_code;

        err_code = nrf_drv_saadc_buffer_convert(p_event->data.done.p_buffer, SAMPLES_IN_BUFFER);
        APP_ERROR_CHECK(err_code);
    }
}
void saadc_init(void)
{
    ret_code_t err_code;
    nrf_saadc_channel_config_t channel_config =
        NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN0);

    err_code = nrf_drv_saadc_init(NULL, saadc_callback);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_channel_init(0, &channel_config);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[0], SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[1], SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);

}

code error points to

Parents
  • Hi,

    Have you enabled the SAADC legacy driver by setting the following define in your sdk_config.h file?

    // <e> SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver - legacy layer
    //==========================================================
    #ifndef SAADC_ENABLED
    #define SAADC_ENABLED 1
    #endif

    Best regards,
    Jørgen

  • Adding the source file and enabling the module should be sufficient. Are you sure that you did not include multiple sdk_config.h files, or if there is something else in the project that overwrites the config?

    Can you upload the project for debugging?

  • Hi,

    I actually fixed the problem using the method you suggested after looking at Jorgen's and Chris's answer. I realized that there is actually two saadc enables and I only enabled the nrfx_saadc_enabled. 

    #ifndef SAADC_ENABLED
    #define SAADC_ENABLED 1
    #endif
    
    #ifndef NRFX_SAADC_ENABLED
    #define NRFX_SAADC_ENABLED 1
    #endif

    However, I am wondering if you can help with a very similar linking issue with the PPI driver. I have added the PPI driver file and enabled it in the sdk_config.h file. However, I am getting a linking error seen below. I have attached the project files for the attached a link for the project. 

    github.com/.../ble_app_template copy

    Building ‘ble_app_template_pca10056_s140’ from solution ‘ble_app_template_pca10056_s140’ in configuration ‘Release’
      Compiling ‘main.c’
      Linking ble_app_template_pca10056_s140.elf
        Output/ble_app_template_pca10056_s140 Release/Obj/main.o: in function `saadc_sampling_event_init':
        undefined reference to `nrf_drv_ppi_init'
    Build failed

Reply
  • Hi,

    I actually fixed the problem using the method you suggested after looking at Jorgen's and Chris's answer. I realized that there is actually two saadc enables and I only enabled the nrfx_saadc_enabled. 

    #ifndef SAADC_ENABLED
    #define SAADC_ENABLED 1
    #endif
    
    #ifndef NRFX_SAADC_ENABLED
    #define NRFX_SAADC_ENABLED 1
    #endif

    However, I am wondering if you can help with a very similar linking issue with the PPI driver. I have added the PPI driver file and enabled it in the sdk_config.h file. However, I am getting a linking error seen below. I have attached the project files for the attached a link for the project. 

    github.com/.../ble_app_template copy

    Building ‘ble_app_template_pca10056_s140’ from solution ‘ble_app_template_pca10056_s140’ in configuration ‘Release’
      Compiling ‘main.c’
      Linking ble_app_template_pca10056_s140.elf
        Output/ble_app_template_pca10056_s140 Release/Obj/main.o: in function `saadc_sampling_event_init':
        undefined reference to `nrf_drv_ppi_init'
    Build failed

Children
No Data
Related