Skip to content

Commit 66db5a4

Browse files
Fix LFCLK sources
LFCLK source was hard-coded to be RC oscillator, now supports all other sources from the tools menu
1 parent 1bfe8ff commit 66db5a4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cores/nRF5/wiring.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ void init( void )
3131
NVIC_ClearPendingIRQ(RTC1_IRQn);
3232
NVIC_EnableIRQ(RTC1_IRQn);
3333

34-
NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk);
34+
#if defined(USE_LFXO)
35+
NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk);
36+
#elif defined(USE_LFSYNT)
37+
NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_Synth << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk);
38+
#else //USE_LFRC
39+
NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk);
40+
#endif
3541
NRF_CLOCK->TASKS_LFCLKSTART = 1UL;
3642

3743
NRF_RTC1->PRESCALER = 0;

0 commit comments

Comments
 (0)