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.

  • I am using the DK at the moment but I would like to use the internal RC clock anyways. Should I calibrate or something like this? And yes, I simplified a little bit the main function but the only difference is the endless loop after. I will edit now so you can see. Do you reckon it is just wasting energy on this infinite loop? I thought the __WFE() function was gonna block (sleep) until receive an event.

Reply Children
No Data
Related