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

SAADC battery measurement current consumption

Hello,

I'm trying to measure battery voltage on nRF52832 chip using SAADC based on examples/peripheral/saadc and examples/ble_peripheral/ble_app_proximity and noticed that just enabling saadc makes my device consume ~7mA constantly.

This is the code for initialization, sampling is later done once per second.

saadc_init code:

ret_code_t                 err_code;
nrf_saadc_channel_config_t channel_config =
    NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_VDD);

err_code = nrf_drv_saadc_init(NULL, _saadc_callback);
APP_ERROR_CHECK(err_code);

err_code = nrf_drv_saadc_channel_init(0, &channel_config);
APP_ERROR_CHECK(err_code);

err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[0], BATTERY_SAADC_SAMPLES_IN_BUFFER);
APP_ERROR_CHECK(err_code);

err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[1], BATTERY_SAADC_SAMPLES_IN_BUFFER);
APP_ERROR_CHECK(err_code);

It doesn't matter if I later sample with nrf_drv_saadc_sample(); or not, the current is being constantly consumed. Just commenting out the code above makes the consumption drop to acceptable levels.

Does anyone had such experience before? I understand that ADC sampling comes at a cost but I didn't expect it to be a constant one.

Parents
  • As Jorgen mentioned 8mA is unusually high for the SAADC. Normal consumption even without the low power steps is around 1mA.

    What might not be obvious in the sample code is that you need to turn off the SAADC when you are done with it. So in your handler once you are done reading the buffer, turn off the saadc and clear pending irq.

    	nrf_drv_saadc_uninit();
        NRF_SAADC->INTENCLR = (SAADC_INTENCLR_END_Clear << SAADC_INTENCLR_END_Pos);
        NVIC_ClearPendingIRQ(SAADC_IRQn);
    

    In this manner it is only on for at most a millisecond total for init, sample, read buffer and turn off.

Reply
  • As Jorgen mentioned 8mA is unusually high for the SAADC. Normal consumption even without the low power steps is around 1mA.

    What might not be obvious in the sample code is that you need to turn off the SAADC when you are done with it. So in your handler once you are done reading the buffer, turn off the saadc and clear pending irq.

    	nrf_drv_saadc_uninit();
        NRF_SAADC->INTENCLR = (SAADC_INTENCLR_END_Clear << SAADC_INTENCLR_END_Pos);
        NVIC_ClearPendingIRQ(SAADC_IRQn);
    

    In this manner it is only on for at most a millisecond total for init, sample, read buffer and turn off.

Children
Related