Skip to content

Commit df4f1a3

Browse files
committed
M487: Adjust placement of SYS_UnlockReg in WDT reset from PD patch
This adjustment has two purposes: 1. Avoid misleading placement of SYS_UnlockReg for WDT clock setting 2. Safer for power-down
1 parent 9bbc8c9 commit df4f1a3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

targets/TARGET_NUVOTON/TARGET_M480/mbed_overrides.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ void mbed_sdk_init(void)
9494
* start of boot process on detecting WDT reset.
9595
*/
9696
if (SYS_IS_WDT_RST()) {
97+
/* Re-unlock to highlight WDT clock setting is protected */
98+
SYS_UnlockReg();
99+
97100
/* Enable IP module clock */
98101
CLK_EnableModuleClock(WDT_MODULE);
99102

@@ -108,8 +111,6 @@ void mbed_sdk_init(void)
108111
*/
109112
NVIC_EnableIRQ(WDT_IRQn);
110113

111-
SYS_UnlockReg();
112-
113114
/* Configure/Enable WDT */
114115
WDT->CTL = WDT_TIMEOUT_2POW4 | // Timeout interval of 2^4 LIRC clocks
115116
WDT_CTL_WDTEN_Msk | // Enable watchdog timer
@@ -123,6 +124,9 @@ void mbed_sdk_init(void)
123124

124125
CLK_PowerDown();
125126

127+
/* Re-unlock for safe */
128+
SYS_UnlockReg();
129+
126130
/* Clear all flags & Disable WDT/INT/WK/RST */
127131
WDT->CTL = (WDT_CTL_WKF_Msk | WDT_CTL_IF_Msk | WDT_CTL_RSTF_Msk | WDT_CTL_RSTCNT_Msk);
128132

0 commit comments

Comments
 (0)