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?

Parents
  • Seems like you are missing the main loop in your code. You main function should look like this:

    int main(void)
    {
        run_ClockMode();
        while(true){
             __WFE();
        }
    }
    

    Without the main loop the CPU will continue into unknown territory.

    If the above was just an error when posting the code here on the forum, one other thing I can think of is that the lfclk_request function requests the external LF clock and that you don't have an external clock (crystal) on your board. If you are using the DK this shouldn't be a problem though.

  • 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?

Reply
  • 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?

Children
No Data
Related