I am using a timer to trigger the SAADC via PPI, and scan 4 channels to EasyDMA, which alternates between two buffers. This all works great most of the time, but if I halt with the debugger or if other areas of my code prevent the interrupt from being serviced in time, sometimes it gets stuck in a state where the DMA sync is off, so the 4 channels don't go to the correct locations and each conversion ends at the wrong time (DMA fills up, causing an interrupt). This is not a major problem because I can detect it and I thought I would be able to reset everything to re-synchronize, but this resetting usually doesn't help. Here's what I'm doing to reset:
nrfx_timer_pause(&IR_DRV_AND_SAMPLE_TIMER);
nrfx_saadc_uninit();
nrf_saadc_buffer_init(nullptr, 0); // Just in case setting the EasyDMA MAXCNT to 0 resets it
// Configure the whole SAADC as usual (code omitted)
// Setup two buffers, since we want one to still be active while we are processing the data from the first:
err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[0], ADC_NUM_SCAN_CHS);
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[1], ADC_NUM_SCAN_CHS);
APP_ERROR_CHECK(err_code);
nrfx_timer_clear(&IR_DRV_AND_SAMPLE_TIMER);
nrf_drv_timer_enable(&IR_DRV_AND_SAMPLE_TIMER);
Are nrfx_saadc_uninit() and nrf_saadc_buffer_init(nullptr, 0) somehow not sufficient to reset the EasyDMA?