Skip to content

Commit 082fd40

Browse files
committed
Added LF clock starting code to SysInit.
1 parent df6bd2f commit 082fd40

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ void SystemInit(void)
9494
}
9595
*(uint32_t volatile *)0x4006EC14 = 0xC0;
9696
}
97+
98+
// Start the external 32khz crystal oscillator.
99+
NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos);
100+
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
101+
NRF_CLOCK->TASKS_LFCLKSTART = 1;
102+
103+
// Wait for the external oscillator to start up.
104+
while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) {
105+
// Do nothing.
106+
}
97107
}
98108

99109

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

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

189189
SystemCoreClockUpdate();
190+
191+
// Start the external 32khz crystal oscillator.
192+
NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos);
193+
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
194+
NRF_CLOCK->TASKS_LFCLKSTART = 1;
195+
196+
// Wait for the external oscillator to start up.
197+
while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) {
198+
// Do nothing.
199+
}
190200
}
191201

192202

0 commit comments

Comments
 (0)