Skip to content
This repository was archived by the owner on Apr 16, 2021. It is now read-only.

Commit 545c4c5

Browse files
committed
PDM: only enable HFCLK if needed
1 parent 6fb51dd commit 545c4c5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

libraries/PDM/src/PDM.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ int PDMClass::begin(int channels, long sampleRate)
4848
{
4949
_channels = channels;
5050

51-
NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
52-
NRF_CLOCK->TASKS_HFCLKSTART = 1;
53-
while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) { }
51+
// Enable high frequency oscillator if not already enabled
52+
if (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) {
53+
NRF_CLOCK->TASKS_HFCLKSTART = 1;
54+
while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) { }
55+
}
5456

5557
// configure the sample rate and channels
5658
switch (sampleRate) {
@@ -133,6 +135,8 @@ void PDMClass::end()
133135
pinMode(_pwrPin, INPUT);
134136
}
135137

138+
// Don't disable high frequency oscillator since it could be in use by RADIO
139+
136140
// unconfigure the I/O and un-mux
137141
nrf_pdm_psel_disconnect();
138142

0 commit comments

Comments
 (0)