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

Power consumption when using app_timer

Hi,

I am struggling with a high power consumption. It is odd, because I have made several low power applications with nRF52 where I get the consumption below 2µA for the entire system in SYSTEM ON mode, just by disabling unused peripherals and avoid any frequent periodic timers.

But now I cannot even initialize the app_timer module without using a lot of power. E.g.:

int main(void)
{
    bool       erase_bonds;
    ret_code_t err_code;

    NRF_POWER->DCDCEN = 1;
    
    APP_ERROR_CHECK(app_timer_init());
    
    while(1) {
        __WFE();
        __SEV();
        __WFE();
   }
}

This code takes 265µA, and if I omit the app_timer_init, it takes just 1,3µA for the complete system.

The RTC is configured to used the external 32kHz crystal.

I have tried to find out exactly what part of the app_timer initialization that results in high current consumption. It is the configuration of the software interrupt handler. But disabling it again does not help anything. 

Is it the High frequency clock that continues to be enabled when software interrupt is configured even when the _SEV is reached? It match the power consumption.

By the way I am using a RayTac MDBT42 module. System running on an CR2032 battery.

Where to look?

Regards

Kasper

Parents
  • Hi,

    You should only see this when the LFCLK is not running, and using the app_timer library without the LFCLK not running does not make any sense. You should see a more sensible number (~2 μA) if you start the LFCLK by adding this code to your main() function:

        NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
        NRF_CLOCK->TASKS_LFCLKSTART = 1;
        while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);

  • Ups, I expected the LFCLK was started automatically when the RTC was initialized, as I have configured NRFX_CLOCK_CONFIG_LF_SRC=1. But it seems that the softdevice has to be enabled before NRFX_CLOCK_CONFIG_LF_SRC takes effect.

    Works better now.

    Thanks.

  • Hi,

    Kasper Leonhardt said:
    Works better now.

    I am glad to hear it is working as expected.

    Kasper Leonhardt said:
    Ups, I expected the LFCLK was started automatically when the RTC was initialized, as I have configured NRFX_CLOCK_CONFIG_LF_SRC=1. But it seems that the softdevice has to be enabled before NRFX_CLOCK_CONFIG_LF_SRC takes effect.

    This can be a bit confusing. The SoftDevice always starts the LF clock when it is initialized, but it does not use the configuration you refer to. The SoftDevice LFCLK configuration is done via the NRF_SDH_CLOCK_LF_* defines in sdk_config.h, assuming you are using the SoftDevice handler library. The NRFX_CLOCK_CONFIG_LF_* macros, on the other hand, are used if you use the nrfx clock driver, which can be useful when not using the SoftDevice (unless you want to access the registers directly, as I suggested in my previous post).

Reply
  • Hi,

    Kasper Leonhardt said:
    Works better now.

    I am glad to hear it is working as expected.

    Kasper Leonhardt said:
    Ups, I expected the LFCLK was started automatically when the RTC was initialized, as I have configured NRFX_CLOCK_CONFIG_LF_SRC=1. But it seems that the softdevice has to be enabled before NRFX_CLOCK_CONFIG_LF_SRC takes effect.

    This can be a bit confusing. The SoftDevice always starts the LF clock when it is initialized, but it does not use the configuration you refer to. The SoftDevice LFCLK configuration is done via the NRF_SDH_CLOCK_LF_* defines in sdk_config.h, assuming you are using the SoftDevice handler library. The NRFX_CLOCK_CONFIG_LF_* macros, on the other hand, are used if you use the nrfx clock driver, which can be useful when not using the SoftDevice (unless you want to access the registers directly, as I suggested in my previous post).

Children
No Data
Related