Observing significantly higher sleep mode current draw when using nrfx_clock interfaces versus using nrf_drv_clock to drive app_timer

Thank you ahead of time for any help that the community can provide. These forums have taught me a lot over the past few weeks.

In my project, I am noticing 20x higher sleep mode current draw when using nrfx_clock interfaces (60uA idle) versus using nrf_drv_clock (3uA idle) to drive app_timer.

  • Issue is reproducible on both nRF52DK and on custom board with nRF52832.
  • Taking current consumption measurements via Power Profiler II in source meter mode. 
  • Actual project includes use of power management, ESB, GPIOs, ADC, most RAM off.
  • No soft devices in use
  • Project built with VSCode/GCC.

I can reproduce the issue with a bare-bones project, although the difference is smaller, as shown in the captures below.

Idle consumption using nrf_drv_clock

Idle consumption using nrfx_clock

Here is a bare-bones project that can easily demonstrate the difference, by changing a single line.

Source code

// TODO - change below to switch between legacy/nrfx interfaces.
#define USE_NRFX_IF

#include "sdk_config.h"

#include "app_timer.h"

#ifdef USE_NRFX_IF
#include "nrfx_clock.h"
static void nrfxClockIrqHandler(nrfx_clock_evt_type_t evt)
{
}
#else
#include "nrf_drv_clock.h"
#endif

int main(void)
{
#ifdef USE_NRFX_IF
    (void)nrfx_clock_init(nrfxClockIrqHandler);
    nrfx_clock_lfclk_start();
#else
    (void)nrf_drv_clock_init();
    nrf_drv_clock_lfclk_request(NULL);
#endif
    app_timer_init();

    while (true)
    {
        __WFE();
    }
}
SDK Config

#ifndef SDK_CONFIG_H
#define SDK_CONFIG_H

#define NRF_LOG_ENABLED 0

#define APP_TIMER_ENABLED              1
#define APP_TIMER_CONFIG_RTC_FREQUENCY 0
#define APP_TIMER_CONFIG_IRQ_PRIORITY  6
#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 10
#define APP_TIMER_CONFIG_USE_SCHEDULER 0
#define APP_TIMER_KEEPS_RTC_ACTIVE     1
#define APP_TIMER_SAFE_WINDOW_MS       300000
#define APP_TIMER_WITH_PROFILER        0
#define APP_TIMER_CONFIG_SWI_NUMBER    1

#ifdef USE_NRFX_IF
#define NRFX_CLOCK_ENABLED             1
#define NRFX_CLOCK_CONFIG_LF_SRC       1
#define NRFX_CLOCK_CONFIG_IRQ_PRIORITY 6
#define NRFX_CLOCK_CONFIG_LOG_ENABLED  0
#else
#define NRF_CLOCK_ENABLED           1
#define CLOCK_CONFIG_LF_SRC         1
#define CLOCK_CONFIG_LF_CAL_ENABLED 0
#define CLOCK_CONFIG_IRQ_PRIORITY   6
#endif

#endif //SDK_CONFIG_H
Makefile
SRC_FILES += \
  $(PROJ_DIR)/main.c \
  $(SDK_ROOT)/components/libraries/timer/app_timer.c \
  $(SDK_ROOT)/components/libraries/util/app_util_platform.c \
  $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_clock.c \
  $(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_clock.c \
  $(SDK_ROOT)/components/boards/boards.c \
  $(SDK_ROOT)/modules/nrfx/mdk/gcc_startup_nrf52.S \
  $(SDK_ROOT)/modules/nrfx/mdk/system_nrf52.c \
Please let me know if anyone can spot something I may be missing that is causing this discrepancy. 

Thank you
-a
Parents
  • Hello,

    For the nRF5 SDK, I generally recommend using the legacy APIs over the nrfx APIs. Most of the drivers have the same features anyway. nrf_drv_clock is also one of the three drivers that can't be migrated to nrfx due to several direct dependencies in our SDK libraries (see "Migration guide for nrfx drivers"). The legacy implementation is tailored specifically for the nRF5 SDK while the nRFX implementation is made to be SDK agnostic and therefore lacks some nRF5 SDK specific adaptations.

    That said, I don't really understand how the nrfx clock driver is affecting the idle current to honest. Especially when you consider that the legacy API is calling the same nRFX driver functions under the hood. There are not any clock configurations for the LF oscillator that should increase the floor current to 11/60 uA that I'm aware of either.

    If you want, you may try my project attached below to see if you see the same discrepancy. With this project I measure around 2.5 uA in both cases (full RAM retention).  The project was  based on the existing /peripheral/rtc example in nRF5 SDK v17.1.0.

    PPK2 plot

    Note: the supply voltage was set to match VDD on the nRF52 DK board to reduce leakage current.

    Attachment:

    rtc.zip

    Best regards,

    Vidar

  • Thank you Vidar, I will try your suggestion and will get back to you. 

Reply Children
No Data
Related