Skip to content

M487: Adjust placement of SYS_UnlockReg in WDT reset code #14524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions targets/TARGET_NUVOTON/TARGET_M480/mbed_overrides.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ void mbed_sdk_init(void)
* start of boot process on detecting WDT reset.
*/
if (SYS_IS_WDT_RST()) {
/* Re-unlock to highlight WDT clock setting is protected */
SYS_UnlockReg();

/* Enable IP module clock */
CLK_EnableModuleClock(WDT_MODULE);

Expand All @@ -108,8 +111,6 @@ void mbed_sdk_init(void)
*/
NVIC_EnableIRQ(WDT_IRQn);

SYS_UnlockReg();

/* Configure/Enable WDT */
WDT->CTL = WDT_TIMEOUT_2POW4 | // Timeout interval of 2^4 LIRC clocks
WDT_CTL_WDTEN_Msk | // Enable watchdog timer
Expand All @@ -123,6 +124,9 @@ void mbed_sdk_init(void)

CLK_PowerDown();

/* Re-unlock for safe */
SYS_UnlockReg();

/* Clear all flags & Disable WDT/INT/WK/RST */
WDT->CTL = (WDT_CTL_WKF_Msk | WDT_CTL_IF_Msk | WDT_CTL_RSTF_Msk | WDT_CTL_RSTCNT_Msk);

Expand Down