How to make the Intermittent application with GRTC and LFXO while asleep.

Hi.

I have been investigating how to use GRTC and LFXO for LFCLK with nRF54L15DK.
In my goal, I would like to make the Intermittent application with sleep and GRTC that works with LFXO even if the MCU stay asleep.

I found the library(nrfx_grtc.h), but I couldn't find the sample named 'GRTC' with the library from ncs 3.0.0.

Do you know how to manipulate the API of GRTC, and properly to write the prj.cof ?


Best regards.

Parents
  • Hello,

    The system clock in Zephyr is already running off the GRTC (or the RTC if you're using a nRF52/53/91 series device). So, let's say you have a single threaded application, you can make it wake up periodically using Zephyr primitives such as k_msleep(). It will be in System ON mode  between the wake ups.

    int main(void)
    {
        while (1) {
            printk("Woke up. Going back to sleep\n);
            k_msleep(1000);  // Sleep for 1000 ms
        }
        
        return 0;
    }

    https://docs.nordicsemi.com/bundle/ncs-3.1.0-preview1/page/nrf/test_and_optimize/optimizing/power_general.html 

    Best regards,

    Vidar

  • HI.
    Thank you for replying, but where did you find GRTC automatically works responding to power state?
    Indeed, I see the k_sleep() go sleep, but I couldn't find that automatic clock source change in your URL document.
    The document seemes to state some techniques for power saving.

    Anyway, I will try obeying your suggested document.
    If I confirm the power consumption become lower, I will report them.

    Best regards.

  • This example should not require any additional modifications besides the configuration changes you made. I also confirmed this by building the same sample on my end. Please try loading the attached hex file to see if you get the same result.

    8468.merged.hex

    nrfutil command to flash the *.hex file from the command line:

    nrfutil device program --firmware merged.hex --options reset=RESET_PIN,verify=VERIFY_READ,chip_erase_mode=ERASE_NONE

  • Hi, Mr.Beng

    Your merged.hex works well as I thought normally. It's correct.


    Then, how should I try next?

    For now, I'll attached below.
    merged.hex (application in my environment)

    6825.merged.hex

    Additionally, I tried debugging with RTTViewer,
    I added them as below in prj.conf.

    CONFIG_USE_SEGGER_RTT=y
    CONFIG_RTT_CONSOLE=y
    CONFIG_UART_CONSOLE=n

    But, Viewer warned invalid RTT control block.

    Is it correct to select zephyr.hex or .map ?
    (I attached the zephyr.elf from systemoff/build/systemoff/zephyr)

    1121.zephyr.hex

    6177.zephyr.map

    Best regards.

  • Hi,

    You can not be in an active debug session or use RTT when testing this sample as the chip cannot enter system OFF when it's in Debug interface mode, see Emulated System OFF mode

  • Hi.

    I see this sample can't be debug, then how do you think the reason why systemoff sample in my environment ?

    In order to solve this, how should I be required for next step?

    I tried adding


    CONFIG_NRF_GRTC_TIMER=y

     in prj.conf

    but, I found the warning as below.

    CONFIG_NRF_GRTC_TIMER was assigned the value y, but got the value n. Missing dependencies:
    DT_HAS_NORDIC_NRF_GRTC_ENABLED
    NRF_GRTC_TIMER set more than once in the active context. Check files under Details View > Config files > Kconfig.. Old value "y", new value "y".
    nRF GRTC Timer
    
    Type: bool
    
    Value: n
    
    This module implements a kernel device driver for the nRF Global Real Time Counter NRF_GRTC and provides the standard "system clock driver" interfaces.
    
    Value has changed in the build

    Is it really effective to enable GRTC?

    Also,

    CONFIG_NRF_GRTC_START_SYSCOUNTER=y

    in nrf54l15dk_nrf54l15_cpuapp_ns_defconfig warned below.

    CONFIG_NRF_GRTC_START_SYSCOUNTER was assigned the value y, but got the value n. Missing dependencies:
    NRF_GRTC_TIMER
    NRF_GRTC_START_SYSCOUNTER set more than once in the active context. Check files under Details View > Config files > Kconfig.. Old value "y", new value "y".
    Start SYSCOUNTER on driver init
    
    Type: bool
    
    Value: n
    
    Start the SYSCOUNTER when initializing the GRTC. This should only be handled by one processor in the system.
    
    Value has changed in the build

    Or, is it required to solder SB3/4/5/6 to enable LFXO?

    Best regards.

  • Hi,

    The only change needed to the "system_off" sample should be to add the following to lines to the prj.conf file:

    CONFIG_GRTC_WAKEUP_ENABLE=y
    CONFIG_GPIO_WAKEUP_ENABLE=n

    You can also add CONFIG_LOG=y for addtional logging.

    I tried to run your merged.hex and it failed here as well. The program entered the secure fault exception handler which means you must have built the project for the nrf54l15dk/nrf54l15/cpuapp/ns instead of nrf54l15dk/nrf54l15/cpuapp/The nrf54l15dk/nrf54l15/cpuapp/ns target is currently not supported for this sample.

    shibuta said:
    Is it really effective to enable GRTC?

    GRTC is always enabled when building a Zephyr application for the nRF54L15 

Reply
  • Hi,

    The only change needed to the "system_off" sample should be to add the following to lines to the prj.conf file:

    CONFIG_GRTC_WAKEUP_ENABLE=y
    CONFIG_GPIO_WAKEUP_ENABLE=n

    You can also add CONFIG_LOG=y for addtional logging.

    I tried to run your merged.hex and it failed here as well. The program entered the secure fault exception handler which means you must have built the project for the nrf54l15dk/nrf54l15/cpuapp/ns instead of nrf54l15dk/nrf54l15/cpuapp/The nrf54l15dk/nrf54l15/cpuapp/ns target is currently not supported for this sample.

    shibuta said:
    Is it really effective to enable GRTC?

    GRTC is always enabled when building a Zephyr application for the nRF54L15 

Children
  • Hi,

    Thank you for replying.
    OK, then,

    Unfortunately, I already build with 'nrf54l15dk/nrf54l15/cpuapp/ns'.

    Just now, I added CONFIG_LOG=y, and I found the log from COM port as below,

    nrf54l15dk system off demo
    Reset by debugger.
    Retained data not supported
    *** Booting nRF Connect SDK v3.0.0-3bfc46578e42 ***
    *** Using Zephyr OS v4.0.99-3e0ce7636fa6 ***
    Entering system off; wait 10 seconds to restart
    [00:00:00.011,780] <err> os: ***** BUS FAULT *****
    [00:00:00.011,785] <err> os:   Precise data bus error
    [00:00:00.011,790] <err> os:   BFAR Address: 0x0
    [00:00:00.011,800] <err> os: r0/a1:  0x00000000  r1/a2:  0x00000001  r2/a3:  0x00000000
    [00:00:00.011,808] <err> os: r3/a4:  0x400cf000 r12/ip:  0x00000000 r14/lr:  0x0004f3df
    [00:00:00.011,812] <err> os:  xpsr:  0x41000000
    [00:00:00.011,816] <err> os: Faulting instruction address (r15/pc): 0x0004bbda
    [00:00:00.011,836] <err> os: >>> ZEPHYR FATAL ERROR 25: Unknown error on CPU 0
    [00:00:00.011,850] <err> os: Current thread: 0x20013748 (unknown)
    [00:00:00.085,693] <err> os: Halting system

    Indeed, you say this sample not supported, but
    why did you succeed in building with this sample ?
    It was because your build environment differs from mine, alright ?

    I just would like to confirm the timer library useful or not while deep-sleep for development.

    Best regards.

  • Hi,

    What I mean is that you must build the project for nrf54l15dk/nrf54l15/cpuapp.

  • Hi.
    I built with 'nrf54l15dk/nrf54l15/cpuapp'.

    But, no any message are found.
    Is it correct?

  • Yes, this is the correct build target for your nrf54L15 DK board. 

    no any message are found.

    Which messages are you referring to? Are you missing the log output:

    *** Booting nRF Connect SDK v3.0.0-3bfc46578e42 ***
    *** Using Zephyr OS v4.0.99-3e0ce7636fa6 ***
    
    nrf54l15dk system off demo
    Reset by debugger.
    Retained data not supported
    Entering system off; wait 2 seconds to restart

    ?

  • Hi.

    Which messages are you referring to? Are you missing the log output:

    This message. After building with 'nrf54l15dk/nrf54l15/cpuapp',no log output found.

    When I re-build with 'nrf54l15dk/nrf54l15/cpuapp/ns', its output recoverd, but remains fail.

    I'll put two building here.

    with 'nrf54l15dk/nrf54l15/cpuapp'

    6371.merged.hex

    with 'nrf54l15dk/nrf54l15/cpuapp/ns'

    merged_ns.hex

    Best regards.

Related