nRF52 - Zephyr application problems - clock source selection - wake up config

Hello,

I have three questions that i could not clarify in an adequate amount of time via Google and DevZone.

Setup:
I am working on a custom board equipped with nRF52805.
We are currently replacing our BLE module from a different manufacturer to one of Nordic.
This is why the board needs to be reverse compatible with our present application/ hardware.
The app must meet the following conditions (only relevant ones for this post):

  • When the main supply is not present, the system is powered from a backup supply battery.
    This is detected via a dedicated GPIO Input.
    In this case the power consumption must be reduced to increase battery life.
  • The nRF52805 / Zephyr must continue keeping track of the time also in low power mode.
    This time value must not be super precise.
    Before connection to a smartphone we need the timestamps from system time to store some data.

Currently I am working with nRF Connect SDK V2.1.0 and Zephyr version: 3.1.99 on VS Code.
Our device functions as a BLE device in peripheral role with a custom UART service to transfer data to a Main uC.

Application:
BLE device, UART, and System Off mode with Ram retention and GPIO wake up is working so far.
Here i did follow the nRF5x System Off demo.
Connections & Data transfer to our Android App do work.

Problem:
Unfortunately i discovered now, that Zephyrs system time does halt when the nRF chip is in system off mode (RTC & all clocks are off).
Which means, i will have to switch to system On mode according to table Electrical specification Sleep.

Changes in the nRF5x System Off demo are minute to achieve this sleep mode.

Config the Pin:

	/* Configure to generate PORT event (wakeup) on supply pin going HIGH. */
	nrf_gpio_cfg_sense_set(NRF_DT_GPIOS_TO_PSEL(DT_ALIAS(supplydetect_pin), gpios),\
                            GPIO_PIN_CNF_SENSE_High);

Entering sleep modes:

void enterSleep(void)
{
    /* Update retained registers */
    retainded_increase_offCount();

    /* sleep System Off */
	//pm_state_force(0u, &(struct pm_state_info){PM_STATE_SOFT_OFF, 0, 0});
	//k_sleep(K_SECONDS(SYS_OFF_SLEEP_S));

    /* sleep System On */
	k_sleep(K_FOREVER);
    
    /* Update retained registers */
    retained_update();

    for (;;) {
        /* reset device to reinitialze system */
        NVIC_SystemReset();
    }
}

Using PPK2 i do see, that the current consumption did increase when changing to systemOn mode.
Consumption increased from ~0.4 uA to ~1uA, which corresponds to the table Electrical specification Sleep.
However nRF52805 does not wake up anymore on GPIO Input level change.

Question:

  1. Which one is the sleep mode with a power consumption as low as possible, where the RTOS still keeps track of its time / ticks?
  2. Why is no wake up happening on PORT event in systemOn mode?
    Do i have to configure the pin as an interrupt pin to trigger the wake up?
    In the tables it is said, wake up on any event. I would suppose the System should wake up with the same pin config as for systemOff mode.

  3. I remember having read, that nRF's Zephyr port uses RTC as a system clock source by default.
    It is not clear to me how nRF's implementation of Zephyr, or Zephyr in general selects clock sources.
    E.g. will LFXO clock be selected automatically if one is present?
    If not is there a Zephyr example that shows how to select this source?

Thank you very much in advance.

Kind regards,
Dino Seiler

Related