From cc05269a570c0412c93d7938ce22ea9311a9dcb3 Mon Sep 17 00:00:00 2001 From: ccli8 Date: Thu, 25 May 2017 17:46:01 +0800 Subject: [PATCH] Move SystemInit() to register unlock range for perhaps future protected register access --- .../TARGET_M451/device/startup_M451Series.c | 9 +++++---- .../TARGET_NUC472/device/startup_NUC472_442.c | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/targets/TARGET_NUVOTON/TARGET_M451/device/startup_M451Series.c b/targets/TARGET_NUVOTON/TARGET_M451/device/startup_M451Series.c index 086c9af697..96d73c12b7 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/device/startup_M451Series.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/device/startup_M451Series.c @@ -271,14 +271,15 @@ void Reset_Handler(void) /* HXT Crystal Type Select: INV */ CLK->PWRCTL &= ~CLK_PWRCTL_HXTSELTYP_Msk; - /* Enable register write-protection function */ - SYS_LockReg(); - /** - * Because EBI (external SRAM) init is done in SystemInit(), SystemInit() must be called at the very start. + * NOTE 1: Unlock is required for perhaps some register access in SystemInit(). + * NOTE 2: Because EBI (external SRAM) init is done in SystemInit(), SystemInit() must be called at the very start. */ SystemInit(); + /* Enable register write-protection function */ + SYS_LockReg(); + #if defined(__CC_ARM) __main(); diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/startup_NUC472_442.c b/targets/TARGET_NUVOTON/TARGET_NUC472/device/startup_NUC472_442.c index 4acab2847c..78c2312785 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/startup_NUC472_442.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/startup_NUC472_442.c @@ -431,14 +431,15 @@ void Reset_Handler(void) /* Disable Power-on Reset function */ SYS_DISABLE_POR(); - /* Enable register write-protection function */ - SYS_LockReg(); - /** - * Because EBI (external SRAM) init is done in SystemInit(), SystemInit() must be called at the very start. + * NOTE 1: Unlock is required for perhaps some register access in SystemInit(). + * NOTE 2: Because EBI (external SRAM) init is done in SystemInit(), SystemInit() must be called at the very start. */ SystemInit(); + /* Enable register write-protection function */ + SYS_LockReg(); + #if defined(__CC_ARM) __main();