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
  • Ok in newer SDK versions this problem is fixed within the nrf_drv_saadc_init function.

    Anyhow after some testing I made a peculiar discovery regarding unitialising the SAADC.
    So far I've configured the SAADC with NRF_SAADC_OVERSAMLE_4X and 2 channels with burst mode active.
    After unitialising the SAADC I have a power consumption somewhere of the neighbourhood of 790µA.
    If I configure the SAADC without oversampling and the channels without burst mode after unitialising the SAADC I get a power consumption around 150µA.

    Does anyone have an idea why there is such a difference?

  • Hi,

    I cannot say exactly why this is, but there are a few issues with the SAADC that could potentially play a part. You could try to look at saadc_anomaly_212_workaround_apply() from modules/hal/nordic/nrfx/drivers/src/nrfx_saadc.c in SDK 17.1.0 and consider doing something like this when uniniting the SAADC driver. That will effectively reset the SAADC peripheral.

Reply Children
Related