Problem after restarting SAADC

Hi,

today I faced a rather strange problem when trying to restart the SAADC.

Bit of context: a requirement for the product I'm developing changed and the device now must advertise in its idle mode instead of entering the system off mode. To save energy I'm trying to deactivate as much as possible and one of these things is the SAADC.

After restarting the SAADC the first sample works without a problem, but the following ones all fail.
After debugging for a bit I found out that nrf_drv_saadc_sample started to return NRF_ERROR_INVALID_STATE.
After digging deeper I saw that after the first sample I receive the event NRF_SAADC_EVENT_STOPPED.

The problem seems to be that after calling nrf_drv_saadc_uninit the flag for NRF_SAADC_EVENT_STOPPED is still set which results in adc_state being set to NRF_SAADC_STATE_IDLE.
This in turn results in nrf_drv_saadc_sample returning NRF_ERROR_INVALID_STATE.

So the way to go is to clear the event after un-initialising the SAADC.

void ADC_Uninit(void)
{
  nrf_drv_saadc_uninit();
  nrf_saadc_event_clear(NRF_SAADC_EVENT_STOPPED);
}

I hope this might help someone if he/she is facing the same problem.

PS: I'm using the nRF52832 with the nRF5SDK version 14.2.0 and the Softdevice 5.1

Parents Reply Children
No Data
Related