This is an FWDGT example for RVSTAR board that explains how to configure the FWDGT module. It shows how to reload the FWDGT counter at regulate period in the main function and trigger the FWDGT reset by using an EXTI interrupt. The FWDGT timeout is set to 1000ms (the timeout may varies due to IRC40K frequency dispersion).
Here are the steps build and run in Nuclei SDK using command line.
# clone nuclei-sdk repo and cd to it
git clone https://github.com/Nuclei-Software/nuclei-sdk
cd nuclei-sdk
# Setup nuclei tools environment following https://doc.nucleisys.com/nuclei_sdk/quickstart.html#setup-tools-and-environment
# Assume you are in Windows, and have create and setup the setup_config.bat file
# source the nuclei tool environment
setup.bat
# clone nuclei-board-labs
git clone https://github.com/Nuclei-Software/nuclei-board-labs
cd nuclei-board-labs/
# cd to this example
cd rvstar/wdgt/fwdgt_key_int
# Build this example for nuclei rvstar board
## clean this example first
make SOC=gd32vf103 BOARD=gd32vf103v_rvstar clean
## build this example
make SOC=gd32vf103 BOARD=gd32vf103v_rvstar all
## connect rvstar board using USB dongle, and make sure driver is setup correctly
## see https://rvmcu.com/column-topic-id-464.html
## upload this example
make SOC=gd32vf103 BOARD=gd32vf103v_rvstar upload
## debug this example
make SOC=gd32vf103 BOARD=gd32vf103v_rvstar debugAfter start-up, the red LED blinks once and then the green LED will blink constantly. When you press the KEY_WAKEUP, the green led stops blink and the blue led light up for approximately 1 second and the red LED will blink once and then the green LED will blink constantly again, which means the system is reset by the FWDGT.
You can also refer to this guide for more details:
If you are not familar with command line, you can also create projects using Nuclei Studio and PlatformIO IDE, put this example code in the IDE and then build, upload and debug on it.
You can create a project in Nuclei Studio IDE or PlatformIO IDE.
Copy the main.c file from this directory and replace the existing application code in the IDE project directory.
Connect RV-STAR board to your PC, build and upload the project and after start-up, the red LED blinks once and then the green LED will blink constantly. When you press the KEY_WAKEUP, the green led stops blink and the blue led light up for approximately 1 second and the red LED will blink once and then the green LED will blink constantly again, which means the system is reset by the FWDGT.