From 7961d2943d70c75d1aaa8f495243a61a397a03ff Mon Sep 17 00:00:00 2001 From: Markus Gyger <182590275+magy00@users.noreply.github.com> Date: Sat, 21 Dec 2024 22:36:57 +0700 Subject: [PATCH] =?UTF-8?q?Overclock=20to=20153.6=20MHz=20(instead=20of=20?= =?UTF-8?q?147.6=20MHz)=20for=20I=C2=B2S=2048=20kHz=20sample=20rate=20(#27?= =?UTF-8?q?08)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/i2s.rst | 2 +- libraries/I2S/src/I2S.cpp | 6 ++---- libraries/I2S/src/I2S.h | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/i2s.rst b/docs/i2s.rst index 2aadcf1..3e1e95a 100644 --- a/docs/i2s.rst +++ b/docs/i2s.rst @@ -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. diff --git a/libraries/I2S/src/I2S.cpp b/libraries/I2S/src/I2S.cpp index d3387c3..b3e7165 100644 --- a/libraries/I2S/src/I2S.cpp +++ b/libraries/I2S/src/I2S.cpp @@ -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; } diff --git a/libraries/I2S/src/I2S.h b/libraries/I2S/src/I2S.h index dfb62f9..bb60e53 100644 --- a/libraries/I2S/src/I2S.h +++ b/libraries/I2S/src/I2S.h @@ -163,5 +163,5 @@ private: 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 };