WDT1 Example
Source code path: example/hal/wdt/wdt1
Supported Platforms
sf32lb52-lcd_n16r8
sf32lb58-lcd_n16r64n4
Overview
This example demonstrates WDT1 usage, including:
WDT1 configuration and enabling.
WDT1 feeding.
WDT1 timeout response.
Example Usage
Hardware Requirements
Before running this example, prepare a development board supported by this example
Compilation and Programming
Switch to the example project directory and run the scons command to execute compilation:
scons --board=sf32lb52-lcd_n16r8 -j32
Run build_sf32lb52-lcd_n16r8_hcpu\uart_download.bat
, select the port as prompted for download:
$ ./uart_download.bat
Uart Download
please input the serial port num:5
For detailed steps on compilation and download, please refer to the relevant introduction in Getting Started Guide.
Expected Results of Example
After the example starts, the serial port outputs as follows:
WDT1 initialization configuration and enabling successful:
10-28 21:27:41:364 WDT Example:
10-28 21:27:41:366 WDT init OK. Timeout: 10(s) Reload2: 60(s)
10-28 21:27:41:368 WDT_CVR0:0x50000 WDT_CVR1:0x1E0000
Tip
In this example, WDT1 working mode (respond mode
) is configured as interrupt and reset
, counting two rounds, with first round counting timeout of 10 seconds and second round counting timeout of 60 seconds.
Feeding the dog (every 5 seconds):
10-28 21:27:46:419 Watchdog feeding.
10-28 21:27:51:332 Watchdog feeding.
10-28 21:27:56:328 Watchdog feeding.
10-28 21:28:01:339 Watchdog feeding.
10-28 21:28:06:329 Watchdog feeding.
10-28 21:28:11:360 Watchdog feeding.
10-28 21:28:16:356 Watchdog feeding.
10-28 21:28:21:368 Watchdog feeding.
10-28 21:28:26:361 Watchdog feeding.
10-28 21:28:31:373 Watchdog feeding.
After stopping feeding the dog, the first round of counting ends (10s), generating an interrupt:
10-28 21:28:31:373 Watchdog feeding.
10-28 21:28:43:793 WDT timeout. Interrupt triggered.
The second round of counting ends (60s), resetting the system:
10-28 21:29:58:197 SFBL
10-28 21:29:59:394 Serial:c2,Chip:4,Package:3,Rev:2 Reason:00000002
10-28 21:29:59:398 NAND ID 0x7070cd
10-28 21:29:59:402 det bbm table with 1, 1, 2
Exception Diagnosis
Confirm WDT configuration status (enable status, count configuration, working mode) through WDT registers:
After WDT is configured correctly, WDT timeout cannot reset the system:
Need to confirm whetherreboot cause
is correctly configured,HAL_PMU_SetWdt()
can be used to add the corresponding WDT’sreboot cause
:/* Add reboot cause for watchdog. */ HAL_PMU_SetWdt((uint32_t)hwdt.Instance);
Reference Documents
Update History
Version |
Date |
Release Notes |
---|---|---|
0.0.1 |
10/2024 |
Initial version |