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

saadc with oversampling + burst with multiple channel failing

hello Slight smile

i am working with nrf52832, s132, sdk 16.0

i am trying to init 3 channels with OVERSUMPELING and BURST enabled:

"

    nrf_drv_saadc_config_t saadc_config;

    //Configure SAADC
    saadc_config.resolution = NRF_SAADC_RESOLUTION_10BIT; 
    saadc_config.oversample = NRF_SAADC_OVERSAMPLE_4X; 
    saadc_config.interrupt_priority = APP_IRQ_PRIORITY_LOW;

    nrf_saadc_channel_config_t channel_config_0 = NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN0);
    nrf_saadc_burst_set(0, NRF_SAADC_BURST_ENABLED);
    nrf_saadc_channel_config_t channel_config_1 = NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN1);
    nrf_saadc_burst_set(1, NRF_SAADC_BURST_ENABLED);
    nrf_saadc_channel_config_t channel_config_2 = NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN2);
    nrf_saadc_burst_set(2, NRF_SAADC_BURST_ENABLED);

   err_code = nrf_drv_saadc_init(&saadc_config, saadc_callback);
   APP_ERROR_CHECK(err_code);

   SET_TO_BATTERY_ADC_CHECK
   err_code = nrf_drv_saadc_channel_init(0, &channel_config_0);
   APP_ERROR_CHECK(err_code);
   err_code = nrf_drv_saadc_channel_init(1, &channel_config_1);
   APP_ERROR_CHECK(err_code);
   err_code = nrf_drv_saadc_channel_init(2, &channel_config_2);
   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);

"

it falls in channel_1 init attempt:

<error> app: ASSERTION FAILED at c:\Nordik SDK\modules\nrfx\drivers\src\nrfx_saadc.c:294<CR><CR><LF>

so 2 questions: 

1. how can i configure and init 3 channels with OVERSAMPLING and BURST enable to be read from the 'saadc_callback' one after the other 

2. if i configure and init only one channel as OVERSAMPLING and BURST can i change the pin in the 'saadc_callback' handler ?

i have tried and it allways falls back to line 294 in the nrfx_saadc.c assertion when i try to init the channel again after uniniting it :

"

     NRF_LOG_INFO("battery: %d", p_event->data.done.p_buffer[0]);
     nrfx_saadc_channel_uninit(0);
     channel_config0.pin_p = NRF_SAADC_INPUT_AIN1;
     err_code = nrf_drv_saadc_channel_init(0, &channel_config0);
     APP_ERROR_CHECK(err_code);

"

best regards

Ziv

Related