Datasheet

Table Of Contents
NOTE
To avoid duplicating logic, this tick is also distributed to the timer (see Section 4.7) and used as the timer reference.
The Pico SDK starts the watchdog tick at the start of day in clocks_init:
Pico SDK: https://github.com/raspberrypi/pico-sdk/tree/pre_release/src/rp2_common/hardware_watchdog/watchdog.c Lines 16 - 19
16 void watchdog_start_tick(uint cycles) {
17 // Important: This function also provides a tick reference to the timer
18 watchdog_hw->tick = cycles | WATCHDOG_TICK_ENABLE_BITS;
19 }
4.8.3. Watchdog Counter
The watchdog counter is loaded by the LOAD register. The current value can be seen in CTRL.TIME.
WARNING
Due to a logic error, the watchdog counter is decremented twice per tick. Which means the programmer needs to
program double the intended count down value. The Pico SDK examples take this issue into account. See RP2040-E1
for more information.
4.8.4. Scratch Registers
The watchdog contains eight 32-bit scratch registers that can be used to store information between soft resets of the
chip. A rst_n_run event triggered by toggling the RUN pin or cycling the digital core supply (DVDD) will reset the scratch
registers.
The bootrom checks the watchdog scratch registers for a magic number on boot. This can be used to soft reset the chip
into some user specified code. See Section 2.7.2.1 for more information.
4.8.5. Programmer’s Model
The Pico SDK provides a hardware_watchdog driver to control the watchdog.
4.8.5.1. Enabling the watchdog
Pico SDK: https://github.com/raspberrypi/pico-sdk/tree/pre_release/src/rp2_common/hardware_watchdog/watchdog.c Lines 36 - 64
36 // Helper function used by both watchdog_enable and watchdog_reboot
37 void _watchdog_enable(uint32_t delay_ms, bool pause_on_debug) {
38 hw_clear_bits(&watchdog_hw->ctrl, WATCHDOG_CTRL_ENABLE_BITS);
39
40 // Reset everything apart from ROSC and XOSC
41 hw_set_bits(&psm_hw->wdsel, PSM_WDSEL_BITS & ~(PSM_WDSEL_ROSC_BITS |
Ê PSM_WDSEL_XOSC_BITS));
42
43 uint32_t dbg_bits = WATCHDOG_CTRL_PAUSE_DBG0_BITS |
44 WATCHDOG_CTRL_PAUSE_DBG1_BITS |
45 WATCHDOG_CTRL_PAUSE_JTAG_BITS;
46
47 if (pause_on_debug) {
RP2040 Datasheet
4.8. Watchdog 568