File tree Expand file tree Collapse file tree 3 files changed +21
-15
lines changed
targets/TARGET_NUVOTON/TARGET_M480 Expand file tree Collapse file tree 3 files changed +21
-15
lines changed Original file line number Diff line number Diff line change @@ -392,10 +392,7 @@ void Reset_Handler_1(void)
392392{
393393 /* Disable register write-protection function */
394394 SYS_UnlockReg ();
395-
396- /* Disable Power-on Reset function */
397- SYS_DISABLE_POR ();
398-
395+
399396 /**
400397 * NOTE 1: Some register accesses require unlock.
401398 * NOTE 2: Because EBI (external SRAM) init is done in SystemInit(), SystemInit() must be called at the very start.
Original file line number Diff line number Diff line change @@ -72,29 +72,22 @@ void mbed_sdk_init(void)
7272 /* Lock protected registers */
7373 SYS_LockReg ();
7474
75- /* Get around h/w issue with reset from deep power-down mode
76- *
77- * When UART interrupt enabled and WDT reset from power-down mode, in the next
78- * cycle, UART interrupt keeps breaking in and cannot block unless via NVIC. To
79- * get around it, we make up a signal of wake-up from deep power-down mode in the
80- * start of boot process on detecting WDT reset.
81- */
75+ /* Get around h/w limit with WDT reset from PD */
8276 if (SYS_IS_WDT_RST ()) {
8377 /* Re-unlock protected clock setting */
8478 SYS_UnlockReg ();
8579
8680 /* Set up DPD power down mode */
8781 CLK -> PMUSTS |= CLK_PMUSTS_CLRWK_Msk ;
88- CLK -> PMUSTS |= CLK_PMUSTS_TMRWK_Msk ;
82+ CLK -> PMUSTS |= CLK_PMUSTS_TMRWK_Msk ;
8983 CLK_SetPowerDownMode (CLK_PMUCTL_PDMSEL_DPD );
9084
91- /* Set up PMU wakeup timer, wakeup interval must be WKTMRIS_256 25.6 ms at least */
9285 CLK_SET_WKTMR_INTERVAL (CLK_PMUCTL_WKTMRIS_256 );
9386 CLK_ENABLE_WKTMR ();
9487
9588 CLK_PowerDown ();
9689
90+ /* Lock protected registers */
9791 SYS_LockReg ();
9892 }
99-
10093}
Original file line number Diff line number Diff line change @@ -39,6 +39,12 @@ reset_reason_t hal_reset_reason_get(void)
3939 reset_reason_t reset_reason_cast ;
4040 uint32_t reset_reason_count = 0 ;
4141
42+ /* Get around h/w limit with WDT reset from PD */
43+ if (CLK -> PMUSTS & CLK_PMUSTS_TMRWK_Msk ) {
44+ /* Per test, these reset reason flags will set with WKT reset. Clear them for this resolution. */
45+ SYS_CLEAR_RST_SOURCE (SYS_RSTSTS_PINRF_Msk | SYS_RSTSTS_PORF_Msk );
46+ }
47+
4248 if (SYS_IS_POR_RST ()) {
4349 reset_reason_cast = RESET_REASON_POWER_ON ;
4450 reset_reason_count ++ ;
@@ -49,7 +55,8 @@ reset_reason_t hal_reset_reason_get(void)
4955 reset_reason_count ++ ;
5056 }
5157
52- if (SYS_IS_WDT_RST ()) {
58+ /* Get around h/w limit with WDT reset from PD */
59+ if (SYS_IS_WDT_RST () || (CLK -> PMUSTS & CLK_PMUSTS_TMRWK_Msk )) {
5360 reset_reason_cast = RESET_REASON_WATCHDOG ;
5461 reset_reason_count ++ ;
5562 }
@@ -103,6 +110,15 @@ uint32_t hal_reset_reason_get_raw(void)
103110void hal_reset_reason_clear (void )
104111{
105112 SYS_CLEAR_RST_SOURCE (SYS -> RSTSTS );
113+
114+ /* Re-unlock protected clock setting */
115+ SYS_UnlockReg ();
116+
117+ /* Get around h/w limit with WDT reset from PD */
118+ CLK -> PMUSTS |= (CLK_PMUSTS_CLRWK_Msk | CLK_PMUSTS_TMRWK_Msk );
119+
120+ /* Lock protected registers */
121+ SYS_LockReg ();
106122}
107123
108124#endif
You can’t perform that action at this time.
0 commit comments