Skip to content

Commit 7961d29

Browse files
authored
Overclock to 153.6 MHz (instead of 147.6 MHz) for I²S 48 kHz sample rate (#2708)
1 parent 4d03edc commit 7961d29

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

docs/i2s.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ sample rate on-the-fly.
7171
bool setSysClk(int samplerate)
7272
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7373
Changes the PICO system clock to optimise for the desired samplerate.
74-
The clock changes to 147.6 MHz for samplerates that are a multiple of 8 kHz, and 135.6 MHz for multiples of 11.025 kHz.
74+
The clock changes to 153.6 MHz for samplerates that are a multiple of 8 kHz, and 135.6 MHz for multiples of 11.025 kHz.
7575
Note that using ``setSysClk()`` may affect the timing of other sysclk-dependent functions.
7676
Should be called before any I2S functions and any other sysclk dependent initialisations.
7777

libraries/I2S/src/I2S.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,10 @@ bool I2S::setFrequency(int newFreq) {
123123

124124
bool I2S::setSysClk(int samplerate) { // optimise sys_clk for desired samplerate
125125
if (samplerate % 11025 == 0) {
126-
set_sys_clock_khz(I2SSYSCLK_44_1, false); // 147.6 unsuccessful - no I2S no USB
127-
return true;
126+
return set_sys_clock_khz(I2SSYSCLK_44_1, false);
128127
}
129128
if (samplerate % 8000 == 0) {
130-
set_sys_clock_khz(I2SSYSCLK_8, false);
131-
return true;
129+
return set_sys_clock_khz(I2SSYSCLK_8, false);
132130
}
133131
return false;
134132
}

libraries/I2S/src/I2S.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,5 @@ class I2S : public Stream, public AudioOutputBase {
163163
int _sm, _smMCLK;
164164

165165
static const int I2SSYSCLK_44_1 = 135600; // 44.1, 88.2 kHz sample rates
166-
static const int I2SSYSCLK_8 = 147600; // 8k, 16, 32, 48, 96, 192 kHz
166+
static const int I2SSYSCLK_8 = 153600; // 8k, 16, 32, 48, 96, 192 kHz
167167
};

0 commit comments

Comments
 (0)