Timed wakeup from deep sleep

I am using an nrf54l10 with the NRFconnect SDK. I would be interested in a solution to go into a low power state and wake up again after a specific time (multiple hours to days). Currently I am using sys_poweroff() but I only found solution to wake the system up via gpio inputs. Is there specific solution recommended for this kind of problem?

Thanks and regards,

Vito

Parents
  • Hi Vito,

    The nRF54L10 can use the GRTC as wakeup source during system OFF. This is demonstrated by the nRF5x System Off sample. Note that it is not enabled in the sample by default, so you need to add CONFIG_GRTC_WAKEUP_ENABLE=y to use it (this is a configuration that is used for this sample only). The key here is configuring wakeup by GRTC before entering system OFF as done by the call to z_nrf_grtc_wakeup_prepare() here.

    Regards,

    Einar

  • Thank you for your help. I tried to implement the sample directly into my code, but when I add CONFIG_GRTC_WAKEUP_ENABLE=y to my proj.conf I get an undefined symbol error. Without this, the code compiles, but does not wake up after 2 seconds as expected.

  • Hi,

    You cannot use in your project. That is a config that only exist in the sample and used there. You can see in main.c how it is used to call z_nrf_grtc_wakeup_prepare() when configured s well as include the needed header file (zephyr/drivers/timer/nrf_grtc_timer.h). That is the only things you need to add to your application, in addition to the code that enters system OFF mode (see the last part of main.c in the sample for that).

  • Yes, this is basically what I did: I just use this 

    	int err = z_nrf_grtc_wakeup_prepare(DEEP_SLEEP_TIME_S * USEC_PER_SEC); // DEEP_SLEEP_TIME_S * USEC_PER_SEC
    
    	if (err != 0) {
    		printk("Unable to prepare GRTC as a wake up source (err = %d).\n", err);
    	} else {
    		printk("Entering system off; wait %u seconds to restart\n", DEEP_SLEEP_TIME_S);
    	}
    	
    	hwinfo_clear_reset_cause();
      	sys_poweroff();

    The code compiles fine and my sample goes to sleep after not sending error message but "Entering system off..." but does not wake up after 2 seconds. Is there anything else I might have missed?

Reply
  • Yes, this is basically what I did: I just use this 

    	int err = z_nrf_grtc_wakeup_prepare(DEEP_SLEEP_TIME_S * USEC_PER_SEC); // DEEP_SLEEP_TIME_S * USEC_PER_SEC
    
    	if (err != 0) {
    		printk("Unable to prepare GRTC as a wake up source (err = %d).\n", err);
    	} else {
    		printk("Entering system off; wait %u seconds to restart\n", DEEP_SLEEP_TIME_S);
    	}
    	
    	hwinfo_clear_reset_cause();
      	sys_poweroff();

    The code compiles fine and my sample goes to sleep after not sending error message but "Entering system off..." but does not wake up after 2 seconds. Is there anything else I might have missed?

Children
  • Hi,

    This looks good (assuming you have the needed include and have defined the values you use). Do you get any build warnings or runetime errors in the log? (If you have not I recommend you test with the sample to see that it works, and then maybe it is easier to debug your application).

  • I got the sample to work on my board. Unfortunately I see the same behavior. After going to sleep the board does not wake up again. I know that its asleep because I can wake it up again via GPIO (button press).  This is my output and then nothing happens.

    *** Booting nRF Connect SDK v3.0.2-89ba1294ac9b ***<\r>
    <\n>*** Using Zephyr OS v4.0.99-f791c49f492c ***<\r>
    <\n><\r>
    <\n>nrf54l15dk system off demo<\r>
    <\n>Reset by debugger.<\r>
    <\n>Retained data not supported<\r>
    <\n>Entering system off; wait 2 seconds to restart
    I had no development board at hand so I installed the sample on one of my custom boards. I had to adjust the proj.conf as I am using the internal 32 kHz Clock: 
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION=y
    CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_LF_ALWAYS_ON=y
    Could this be a reason for the sample to not work as intended?
  • Hi,

    I see. Wakeup from system OFF is only possible using LFXO (with external 32.768 kHz crystal). This is described indirectly under LFCLK controller:

    LFXO can run in System OFF mode. The other clock sources only run in System ON mode.

    So you your options are to use system ON low power mode (the normal sleep mode where the CPU sleeps and you put other peripherals in low power states), use another wakeup source, or add a 32.768 kHz crystal to your custom board.

  • Thank you we added a 32.768 kHz crystal and it worked. 

Related