Hello. I have a problem when using nrfx_saadc. I try to start the sampling right after the SAADC offset calibration, but it doesn't happen and the program hangs. Only if I add a delay(4ms) before the measurement, then everything works as it should. I also noticed that if I do not add this delay before nrfx_saadc_sample() function calling, SAADC generate EVENT_END event.
SAADC Configuration:
- Resolution 14bit
- Oversampling 128x
- Interrupt priority 6
- Low power mode is turned ON.
Here is the code I use to run measurements after calibration:
if(p_event->type == NRFX_SAADC_EVT_CALIBRATEDONE)
{
// Start new accurate measurement
nrf_delay_ms(4); //Only if I add delay saadc measurement is occurring
ret_code_t err_code = tenso_saadc_measure();
NRF_LOG_INFO("Calibration done");
APP_ERROR_CHECK(err_code);
return;
}Source code of tenso_saadc_measure:
static ret_code_t tenso_saadc_measure()
{
ret_code_t err_code = nrfx_saadc_buffer_convert(&(m_cb.tenso_adc_buf), 1);
if(err_code) return err_code;
err_code = nrfx_saadc_sample();
if(err_code) return err_code;
return err_code;
}
Tell me why this happens, maybe I'm wrong in something?
Thanks in advance for your reply.