Skip to content

Commit 10c803e

Browse files
committed
Add LF clock initialization in startup sequence.
1 parent 38671de commit 10c803e

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

hal/targets/cmsis/TARGET_NORDIC/TARGET_NRF5/TARGET_MCU_NRF51822/system_nrf51.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ void SystemInit(void)
9494
}
9595
*(uint32_t volatile *)0x4006EC14 = 0xC0;
9696
}
97+
98+
NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos);
99+
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
100+
NRF_CLOCK->TASKS_LFCLKSTART = 1;
101+
102+
while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) {
103+
// wait for the low frequency clock start
104+
}
97105
}
98106

99107

hal/targets/cmsis/TARGET_NORDIC/TARGET_NRF5/TARGET_MCU_NRF52832/system_nrf52.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,15 @@ void SystemInit(void)
187187
#endif
188188

189189
SystemCoreClockUpdate();
190+
191+
NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos);
192+
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
193+
NRF_CLOCK->TASKS_LFCLKSTART = 1;
194+
195+
while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) {
196+
// wait for the low frequency clock start
197+
}
198+
190199
}
191200

192201

0 commit comments

Comments
 (0)