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

current increases by about 1.5 mA after a battery check.

Hi all.

Consumption current increases by about 1.5 mA after a battery check.

uint8_t battery_start(void) { // Configure ADC NRF_ADC->INTENSET = ADC_INTENSET_END_Msk; NRF_ADC->CONFIG = (ADC_CONFIG_RES_8bit << ADC_CONFIG_RES_Pos) | (ADC_CONFIG_INPSEL_SupplyOneThirdPrescaling << ADC_CONFIG_INPSEL_Pos) | (ADC_CONFIG_REFSEL_VBG << ADC_CONFIG_REFSEL_Pos) | (ADC_CONFIG_PSEL_Disabled << ADC_CONFIG_PSEL_Pos) | (ADC_CONFIG_EXTREFSEL_None << ADC_CONFIG_EXTREFSEL_Pos); NRF_ADC->EVENTS_END = 0; NRF_ADC->ENABLE = ADC_ENABLE_ENABLE_Enabled;

NRF_ADC->EVENTS_END  = 0;    // Stop any running conversions.
NRF_ADC->TASKS_START = 1;

while (NRF_ADC->EVENTS_END == 0)
{

}
{
    uint8_t     adc_result;
    uint16_t    batt_lvl_in_milli_volts;
    uint32_t    err_code;

    NRF_ADC->EVENTS_END     = 0;
    adc_result              = NRF_ADC->RESULT;
    NRF_ADC->TASKS_STOP     = 1;

    batt_lvl_in_milli_volts = ADC_RESULT_IN_MILLI_VOLTS(adc_result) +
                              DIODE_FWD_VOLT_DROP_MILLIVOLTS;
	NRF_ADC->INTENSET = 0;
	NRF_ADC->INTENCLR   = 0x1;
	NRF_ADC->CONFIG     = 0;
	NRF_ADC->EVENTS_END = 0;
	NRF_ADC->TASKS_START = 0;
	NRF_ADC->ENABLE     = 0;

*this point return battery_level_in_percent(batt_lvl_in_milli_volts); } }

BR, Suzuki.

  • I have the same issue. Please post a solution here if you figure it out Suzuki.

  • I solved my issue, I had this line at the start of my adc routine:NRF_ADC->INTENSET = ADC_INTENSET_END_Msk;

    After removing it, I got back to the expected consumption. (it was 2-3mA too high)

    My code that works now is:

    uint16_t adc_result;
    	
    // Configure ADC
    NRF_ADC->CONFIG   = (ADC_CONFIG_RES_BATT << ADC_CONFIG_RES_Pos) |
                        (ADC_CONFIG_INPSEL_SupplyOneThirdPrescaling << ADC_CONFIG_INPSEL_Pos) |
                        (ADC_CONFIG_REFSEL_VBG << ADC_CONFIG_REFSEL_Pos) |
                        (ADC_CONFIG_PSEL_Disabled << ADC_CONFIG_PSEL_Pos) |
                        (ADC_CONFIG_EXTREFSEL_None << ADC_CONFIG_EXTREFSEL_Pos);
    NRF_ADC->EVENTS_END = 0;
    NRF_ADC->ENABLE     = ADC_ENABLE_ENABLE_Enabled;
    
    NRF_ADC->TASKS_START = 1;
    
    while (NRF_ADC->EVENTS_END == 0) ;
    
    NRF_ADC->EVENTS_END = 0;
    adc_result          = NRF_ADC->RESULT;
    NRF_ADC->TASKS_STOP = 1;
    
    batt_lvl_in_milli_volts = ADC_RESULT_IN_MILLI_VOLTS(adc_result) +
                              DIODE_FWD_VOLT_DROP_MILLIVOLTS;
    
    	NRF_ADC->ENABLE     = ADC_ENABLE_ENABLE_Disabled;
    
    return batt_lvl_in_milli_volts;
    
  • My issue was indeed enabling the ADC interrupt, same as in this thread: devzone.nordicsemi.com/.../ But I'm not sure if my issue is the same as yours, since you do not enable the adc interrupt in the code you posted. Have you checked the current consumption increase with and without debugger enabled? Any other peripherals keeping the hfclock running?

Related