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

Current consumption NRF52

I'm struggling with current consumption. I need my device to completely sleep and leave only the RTC on when the ext power is off (run on battery). After making sure my RTC was actually working, I ran the following code:

void run_ClockMode()
{
	uint32_t err_code;

	err_code = nrf_drv_clock_init();

	nrf_drv_clock_lfclk_request(NULL);

	while (!nrf_drv_clock_lfclk_is_running());

    static uint32_t APP_TIMER_BUF[CEIL_DIV(APP_TIMER_BUF_SIZE(1), sizeof(uint32_t))];
    err_code = app_timer_init((4095), 2, APP_TIMER_BUF, 0);

	err_code = app_timer_create(&MainRTC, APP_TIMER_MODE_REPEATED, MainRTC_handler);

	app_timer_start(MainRTC, APP_TIMER_TICKS(1000, 4095), NULL);
}

int main(void)
{
run_ClockMode();
__WFE();
__SEV();
__WFE();
for (;;) {};
}

and the RTC handler is empty. However, is consuming up to 5mA when only the battery is connected. If I dont call the run_ClockMode() then it falls down to 1.6uA. I also tried this:

void run_ClockMode()
{
uint32_t err_code;

err_code = nrf_drv_clock_init();

nrf_drv_clock_lfclk_request(NULL);
}

without actually running the RTC but just the LFCLK. But it's still at least 1mA. Am I missing something here?

  • Ok, I tested with only the WFE inside the loop. Now it dropped the current consumption. However, I still get around 12 uA. The code is exaclty like the first code on my original post but with WFE inside an infinite loop. Am I still missing to achieve "System ON, no RAM retention + RTC + LFRC = 1.2uA + 0.1uA + 0.6uA = 1.9uA"?

  • I tested your code and seems like you forgot the APP_TIMER_DEF macro to initialize the MainRTC variable. Also you should use the APP_TIMER_INIT macro so the buffer size is initialized correctly. something like this:

    #define PRESCALER 4095
    #define TIMER_DELAY 1000
    void run_ClockMode()
    {
        nrf_drv_clock_init();
        nrf_drv_clock_lfclk_request(NULL);
        while (!nrf_drv_clock_lfclk_is_running());
        APP_TIMER_INIT(PRESCALER, 1, NULL);
        APP_TIMER_DEF(MainRTC);
        app_timer_create(&MainRTC, APP_TIMER_MODE_REPEATED, MainRTC_handler);
        app_timer_start(MainRTC, APP_TIMER_TICKS(TIMER_DELAY, PRESCALER), NULL);
    }
    

    I measured on this code and it gave me about 2uA in average between the timer interrupts.

  • Sorry about that, I do have the MainRTC definition outside the functions. And the buffer and other stuff I literally copied the code from inside APP_TIMER_INIT macro anyways. I found the problem... I have no clue why but after I program, I turn on the board without the USB cable to measure the current but the LED called LD5 keeps flashing nonstop. I'm using external power supply set to 3.3V and I opened the SB9 to measure the current. But after just powering off and on again the LD5 goes off then I can sense 2.0uA. Funny that happened sometimes only... it seems only in the first time I power on the board right after programming it happens. Then all the other times it powers on normally without LD5 flashing and already measuring 2uA. I don't know if I was clear enough, but any tips about that?

  • When LD5 is flashing fast, I think it means that the JLink has not initialized the driver yet. I've seen this problem in linux, where I sometimes have to reset the kit in order for it to reinitialize the driver, if not it will just continue flashing. Can't remember I've seen this on windows though, but you can try to install the latest driver from here: J-Link Software and Documentation Pack

Related