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

SAADC in SDK15.2 issue in nrfx_saadc.c nrfx_saadc_abort

Using SDK15.2 on nRF52832 in file nrfx_saadc.c function nrfx_saadc_abort.

I keep getting an error in the nrfx_saadc_abort function when I try to abort. Looking at the logic in the function it doesn't make sense to wait for the state to NOT be idle:

// Wait for ADC being stopped.
bool result;
NRFX_WAIT_FOR((m_cb.adc_state != NRF_SAADC_STATE_IDLE), HW_TIMEOUT, 0, result);
NRFX_ASSERT(result);

Looks like the SDK copied the logic from https://devzone.nordicsemi.com/f/nordic-q-a/29806/nrf52832-sdk14---saadc-calibration-issues/118302#118302

I think the correct logic for the NRFX_WAIT_FOR is:

NRFX_WAIT_FOR((m_cb.adc_state == NRF_SAADC_STATE_IDLE), HW_TIMEOUT, 0, result);

After making this change I no longer error on the assert.

Related