Datasheet

Table Of Contents
4.7.5.2. Updating the watchdog counter
SDK: https://github.com/raspberrypi/pico-sdk/tree/master/src/rp2_common/hardware_watchdog/watchdog.c Lines 23 - 27
23 static uint32_t load_value;
24
25 void watchdog_update(void) {
26 watchdog_hw->load = load_value;
27 }
4.7.5.3. Usage
The Pico Examples repository provides a hello_watchdog example that uses the hardware_watchdog to demonstrate
use of the watchdog.
Pico Examples: https://github.com/raspberrypi/pico-examples/tree/master/watchdog/hello_watchdog/hello_watchdog.c Lines 11 - 33
11 int main() {
12 stdio_init_all();
13
14 if (watchdog_caused_reboot()) {
15 printf("Rebooted by Watchdog!\n");
16 return 0;
17 } else {
18 printf("Clean boot\n");
19 }
20
21 // Enable the watchdog, requiring the watchdog to be updated every 100ms or the chip will
Ê reboot
22 // second arg is pause on debug which means the watchdog will pause when stepping through
Ê code
23 watchdog_enable(100, 1);
24
25 for (uint i = 0; i < 5; i++) {
26 printf("Updating watchdog %d\n", i);
27 watchdog_update();
28 }
29
30 // Wait in an infinite loop and don't update the watchdog so it reboots us
31 printf("Waiting to be rebooted by watchdog\n");
32 while(1);
33 }
4.7.6. List of Registers
The watchdog registers start at a base address of 0x40058000 (defined as WATCHDOG_BASE in SDK).
Table 555. List of
WATCHDOG registers
Offset Name Info
0x00 CTRL Watchdog control
0x04 LOAD Load the watchdog timer.
0x08 REASON Logs the reason for the last reset.
0x0c SCRATCH0 Scratch register
0x10 SCRATCH1 Scratch register
RP2040 Datasheet
4.7. Watchdog 567