Hi Wang baode,
Please go for download the FRDM-KExx Driver Library package which contains the Watchdog demo for the KE02 through the link as below.
https://cache.nxp.com/files/microcontrollers/software/device_drivers/KEXX_DRIVERS_V1.2.1_DEVD.zip
Have a great day,
Ping
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello
The following is the KE02 watchdog configuration code from the uTasker project:
UNLOCK_WDOG();
WDOG_CS2 = (WDOG_CS2_CLK_1kHz | WDOG_CS2_FLG);
WDOG_TOVAL = BIG_SHORT_WORD(2000); // 2s timeout
WDOG_WIN = 0; // disable windowing operation
WDOG_CS1 = (/*WDOG_CS1_UPDATE | */WDOG_CS1_EN); // enable
It configured a 2s watchdog timeout based on the 1kHz IRC clock.
UNLOCK_WDOG() is WDOG_REFRESH = 0x20c5; WDOG_REFRESH = 0x28d9
The WDOG_CS1_UPDATE flag can be used to allow the watchdog to be reconfigured, rather than being locked from further modification.
Note that the TOVAL is in big-endian format, which often catches people out. Some (original) user manuals incorrectly gave code examples which wrote it in little-endian format which confused.
Regards
Mark