Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Using ADC with a NRF52811

Hi,

I try to use the ADC of a NRF52811. The ADC input is on p.030,

that should be AIN6 according the datasheet.

The following I'm doing for initialization and I call over an app timer the function

nrf_drv_saadc_buffer_convert(p_event->data.done.p_buffer, 1); every 5000ms.

I never get any saadc_callback response, so, what I'm missing in my initialization?

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, 1);
        APP_ERROR_CHECK(err_code);

        int i;
        NRF_LOG_INFO("ADC value: %d", (int)p_event->data.done.p_buffer[0]);
    }
}


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_AIN6);

    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(&adc_v_bat, 1);
    APP_ERROR_CHECK(err_code);
}

Parents Reply Children
No Data
Related