Datasheet

Table Of Contents
ROSC to stop the output clock.
NOTE
the PLLs must be stopped before entering DORMANT mode
Pico SDK: https://github.com/raspberrypi/pico-sdk/tree/pre_release/src/rp2_common/hardware_xosc/xosc.c Lines 41 - 46
41 void xosc_dormant(void) {
42 // WARNING: This stops the xosc until woken up by an irq
43 xosc_hw->dormant = XOSC_DORMANT_VALUE_DORMANT;
44 // Wait for it to become stable once woken up
45 while(!(xosc_hw->status & XOSC_STATUS_STABLE_BITS));
46 }
WARNING
If no IRQ is configured before going into dormant mode the XOSC or ROSC will never restart.
See Section 2.10.5.2 for a complete example of dormant mode using the XOSC.
2.15.5. XOSC COUNTER
The COUNT register provides a method of managing short software delays. Writing a value to the COUNT register
automatically triggers it to start counting down to zero at the XOSC frequency. The programmer then simply polls the
register until it reaches zero. This is preferrable to using NOPs in software loops because it is independent of the core
clock frequency, the compiler and the execution time of the compiled code.
2.15.6. Programmer’s Model
Pico SDK: https://github.com/raspberrypi/pico-sdk/tree/pre_release/src/rp2040/hardware_structs/include/hardware/structs/xosc.h Lines 15 - 26
15 typedef struct {
16 io_rw_32 ctrl;
17 io_rw_32 status;
18 io_rw_32 dormant;
19 io_rw_32 startup;
20 io_rw_32 div2;
21 io_rw_32 padrefclk;
22 io_rw_32 clksrc;
23 io_rw_32 count;
24 } xosc_hw_t;
25
26 #define xosc_hw ((xosc_hw_t *const)XOSC_BASE)
Pico SDK: https://github.com/raspberrypi/pico-sdk/tree/pre_release/src/rp2_common/hardware_xosc/xosc.c Lines 16 - 30
16 void xosc_init(void) {
17 // Assumes 1-15 MHz input
18 assert(XOSC_MHZ <= 15);
19 xosc_hw->ctrl = XOSC_CTRL_FREQ_RANGE_VALUE_1_15MHZ;
20
21 // Set xosc startup delay
22 uint32_t startup_delay = (((12 * MHZ) * (MS) + 128) / 256);
RP2040 Datasheet
2.15. Crystal Oscillator (XOSC) 193