Datasheet

Table Of Contents
CAUTION
Memories must not be accessed when powered down. Doing so can corrupt memory contents.
When powering a memory back up, a 20 ns delay is required before accessing the memory again.
The XIP cache (see Section 2.6.3) can also be powered down, with CTRL.POWER_DOWN. The XIP hardware will not
generate cache accesses whilst the cache is powered down. Note that this is unlikely to produce a net power savings if
code continues to execute from XIP, due to the comparatively high voltages and switching capacitances of the external
QSPI bus.
2.11.5. Programmer’s Model
2.11.5.1. Sleep
The hello_sleep example, https://github.com/raspberrypi/pico-playground/tree/master/sleep/hello_sleep/hello_sleep.c,
demonstrates sleep mode. The hello_sleep application (and underlying functions) takes the following steps:
Run all clocks in the system from XOSC
Configure an alarm in the RTC for 10 seconds in the future
Set clk_rtc as the only clock running in sleep mode using the SLEEP_ENx registers (see SLEEP_EN0)
Enable deep sleep in the processor
Call __wfi on processor which will put the processor into deep sleep until woken by the RTC interrupt
The RTC interrupt clears the alarm and then calls a user supplied callback function
The callback function ends the example application
NOTE
It is necessary to enable deep sleep on both proc0 and proc1 and call __wfi, as well as ensure the DMA is stopped to
enter sleep mode.
hello_sleep makes use of functions in pico_sleep of the Pico Extras. In particular, sleep_goto_sleep_until puts the
processor to sleep until woken up by an RTC time assumed to be in the future.
Pico Extras: https://github.com/raspberrypi/pico-extras/tree/master/src/rp2_common/pico_sleep/sleep.c Lines 106 - 122
106 void sleep_goto_sleep_until(datetime_t *t, rtc_callback_t callback) {
107 // We should have already called the sleep_run_from_dormant_source function
108 assert(dormant_source_valid(_dormant_source));
109
110 // Turn off all clocks when in sleep mode except for RTC
111 clocks_hw->sleep_en0 = CLOCKS_SLEEP_EN0_CLK_RTC_RTC_BITS;
112 clocks_hw->sleep_en1 = 0x0;
113
114 rtc_set_alarm(t, callback);
115
116 uint save = scb_hw->scr;
117 // Enable deep sleep at the proc
118 scb_hw->scr = save | M0PLUS_SCR_SLEEPDEEP_BITS;
119
120 // Go to sleep
121 __wfi();
122 }
RP2040 Datasheet
2.11. Power Control 189