Skip to content

Commit

Permalink
Overclock to 153.6 MHz (instead of 147.6 MHz) for I²S 48 kHz sample r…
Browse files Browse the repository at this point in the history
…ate (#2708)
  • Loading branch information
magy00 authored Dec 21, 2024
1 parent 4d03edc commit 7961d29
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/i2s.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ sample rate on-the-fly.
bool setSysClk(int samplerate)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Changes the PICO system clock to optimise for the desired samplerate.
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.
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.
Note that using ``setSysClk()`` may affect the timing of other sysclk-dependent functions.
Should be called before any I2S functions and any other sysclk dependent initialisations.

Expand Down
6 changes: 2 additions & 4 deletions libraries/I2S/src/I2S.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,10 @@ bool I2S::setFrequency(int newFreq) {

bool I2S::setSysClk(int samplerate) { // optimise sys_clk for desired samplerate
if (samplerate % 11025 == 0) {
set_sys_clock_khz(I2SSYSCLK_44_1, false); // 147.6 unsuccessful - no I2S no USB
return true;
return set_sys_clock_khz(I2SSYSCLK_44_1, false);
}
if (samplerate % 8000 == 0) {
set_sys_clock_khz(I2SSYSCLK_8, false);
return true;
return set_sys_clock_khz(I2SSYSCLK_8, false);
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/I2S/src/I2S.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,5 @@ class I2S : public Stream, public AudioOutputBase {
int _sm, _smMCLK;

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

0 comments on commit 7961d29

Please sign in to comment.