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

Adc consumption

Hello all,

I am trying to activate ADC to measure a voltage every few seconds using nrf51822. When it is done, I supposedly deactivate ADC so it does not consumes while I don't need it. I find that the consumption increases when I activate the ADC, but it does not decreases when it is finished, so I suppose I am not deactivating well.

Code:

Every few seconds, I run this function:

void measure_voltage(void)
{
	uint32_t err_code;
    // 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;

    // Enable ADC interrupt
    err_code = sd_nvic_ClearPendingIRQ(ADC_IRQn);
    APP_ERROR_CHECK(err_code);

    err_code = sd_nvic_SetPriority(ADC_IRQn, NRF_APP_PRIORITY_LOW);
    APP_ERROR_CHECK(err_code);

    err_code = sd_nvic_EnableIRQ(ADC_IRQn);
    APP_ERROR_CHECK(err_code);

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

Then, I wait for the handler to come up:

void ADC_IRQHandler(void) 
{
    if (NRF_ADC->EVENTS_END != 0)
    {
        uint8_t     adc_result;

        NRF_ADC->EVENTS_END     = 0;
        adc_result              = NRF_ADC->RESULT;
        NRF_ADC->TASKS_STOP     = 1;
	    NRF_ADC->ENABLE     = ADC_ENABLE_ENABLE_Disabled;
			
	    paquet_advertising[0]=adc_result;
	}
}

Am I missing something?

Thank you very much

Parents
  • Hi

    I have generally in the past not found a reason to disable the ADC after sampling is finished. I have obtained low current without it. What current are you seeing when ADC enabled and not sampling?

    I have generally used this code with low current consumption. When there sampling ongoing the current consumption should be around 1mA, as the ADC consumes ~260uA and it needs 16MHz clock to opterate, adding up to the 1mA current consumption. If you have a multimeter to measure current consumption, you would need more low frequency sampling example than the one I just linked to. Here is more relevant example that is made for SDK 8.1.0 and the nRF51-DK where you can also adjust the sampling frequency to a very small value, which will enable you to see the current consumption on a multimeter between sampling events. You should see around ~3uA when not sampling

    rtc0-triggering-adc-sample_nrf51DK.zip

    Make the NRF_RTC0->CC[0] value larger to slow down the sampling frequency

Reply
  • Hi

    I have generally in the past not found a reason to disable the ADC after sampling is finished. I have obtained low current without it. What current are you seeing when ADC enabled and not sampling?

    I have generally used this code with low current consumption. When there sampling ongoing the current consumption should be around 1mA, as the ADC consumes ~260uA and it needs 16MHz clock to opterate, adding up to the 1mA current consumption. If you have a multimeter to measure current consumption, you would need more low frequency sampling example than the one I just linked to. Here is more relevant example that is made for SDK 8.1.0 and the nRF51-DK where you can also adjust the sampling frequency to a very small value, which will enable you to see the current consumption on a multimeter between sampling events. You should see around ~3uA when not sampling

    rtc0-triggering-adc-sample_nrf51DK.zip

    Make the NRF_RTC0->CC[0] value larger to slow down the sampling frequency

Children
No Data
Related