This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Unable to disable SAADC on NRF52832

Hi,

I'm developing a simple sensor application using s132 on NRF52832_XXAA. The application works fine, except that I have problems disabling the saadc module after conversion. I check battery voltage once per minute and the readings are always correct, but at the first conversion the current consumption jumps from less than 100uA to 7mA and stays there until i reset the chip.

How come the adc draw 7mA? It's a lot. I could live with that since it's for a fraction of a second once per minute. But how come i can't disable it? Is something missing in the code below?

Thanks in advance, Mike

#include "nrf.h"
#include "nrf_drv_saadc.h"
#include "app_error.h"
#include "app_util_platform.h"
#include "nrf_log.h"
#include "adc.h"

static void adc_callback(nrf_drv_saadc_evt_t const *e)
{
}

static void adc_enable()
{
    int32_t r;
	nrf_drv_saadc_config_t cfg;
    nrf_saadc_channel_config_t ch;

	cfg.resolution = NRF_SAADC_RESOLUTION_14BIT;
	cfg.oversample = NRF_SAADC_OVERSAMPLE_DISABLED;
	cfg.interrupt_priority = 7;
	cfg.low_power_mode = 1;	

    r = nrf_drv_saadc_init(&cfg, adc_callback);
    APP_ERROR_CHECK(r);

	ch.resistor_p = NRF_SAADC_RESISTOR_DISABLED;
	ch.resistor_n = NRF_SAADC_RESISTOR_DISABLED;
	ch.gain = NRF_SAADC_GAIN1_6;
	ch.reference = NRF_SAADC_REFERENCE_INTERNAL; // 0.6V internal ref
	ch.acq_time = NRF_SAADC_ACQTIME_10US;
	ch.mode = NRF_SAADC_MODE_SINGLE_ENDED;
	ch.burst = NRF_SAADC_BURST_DISABLED;
	ch.pin_p = NRF_SAADC_INPUT_VDD;
	ch.pin_n = NRF_SAADC_INPUT_DISABLED;

    r = nrf_drv_saadc_channel_init(0, &ch);
    APP_ERROR_CHECK(r);
}

static void adc_disable()
{
    int32_t r;

	r = nrf_drv_saadc_channel_uninit(0);
    APP_ERROR_CHECK(r);
	nrf_drv_saadc_uninit();
}

int32_t adc_sample(int16_t *value)
{
	int32_t r;

	adc_enable();
	r = nrf_drv_saadc_sample_convert(0, value);
	adc_disable();

    APP_ERROR_CHECK(r);
	return r;
}
Related