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

About SAADC, Easy-DMA and channels (nRF5_SDK)

There's an example saadc_pca10036 in the SDK. I am wondering how this piece of code works in that example:

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

Specifically, why there are two calls of same function, nrf_drv_saadc_buffer_convert()? Does it set some kind of double-buffering?

In my case, I have four ADC-inputs I want to sample 200 times per second each. How should I configure the SAADC subsystem?

EDIT: Also, how do I know which channel was triggered when I get into the callback (below)?

void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
{
   if (p_event->type == NRF_DRV_SAADC_EVT_DONE)
   ...
Related