Skip to content

Commit a766738

Browse files
authored
Merge pull request #367 from tomaszduda23/master
fix boot loop due to wrong value read from REGOUT0
2 parents 6a9a6a3 + 6250be4 commit a766738

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/boards/boards.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ void board_init(void) {
111111
// #define UICR_REGOUT0_VALUE UICR_REGOUT0_VOUT_3V3
112112
// in board.h when using that power configuration.
113113
#ifdef UICR_REGOUT0_VALUE
114+
// for some reason bellow condition is true even though debugger show 3.0V
115+
// pyocd> rw 0x10001304
116+
// 10001304: fffffffc
117+
// it leads to infinite boot loop. Let wait for NVM to be ready first.
118+
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
119+
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
114120
if ((NRF_UICR->REGOUT0 & UICR_REGOUT0_VOUT_Msk) == (UICR_REGOUT0_VOUT_DEFAULT << UICR_REGOUT0_VOUT_Pos)){
115121
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
116122
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
@@ -119,8 +125,10 @@ void board_init(void) {
119125

120126
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
121127
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
122-
123-
NVIC_SystemReset();
128+
// to avoid infinity boot loop reset only if REGOUT0 was set correctly
129+
if((NRF_UICR->REGOUT0 & UICR_REGOUT0_VOUT_Msk) == (UICR_REGOUT0_VALUE << UICR_REGOUT0_VOUT_Pos)){
130+
NVIC_SystemReset();
131+
}
124132
}
125133
#endif
126134

0 commit comments

Comments
 (0)