From 2965bac64cf4a4518cb2b3e019ab681560365967 Mon Sep 17 00:00:00 2001 From: Josh Weberruss Date: Fri, 7 Apr 2023 17:26:39 +1000 Subject: [PATCH] Use 192 as mclk_multiple for 24-bit I2S --- esp-hal-common/src/i2s.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/esp-hal-common/src/i2s.rs b/esp-hal-common/src/i2s.rs index 5da5bf059..fca4f4a2e 100644 --- a/esp-hal-common/src/i2s.rs +++ b/esp-hal-common/src/i2s.rs @@ -1978,7 +1978,9 @@ mod private { // // main difference is we are using fixed-point arithmetic here - let mclk_multiple = 256; + // If data_bits is a power of two, use 256 as the mclk_multiple + // If data_bits is 24, use 192 (24 * 8) as the mclk_multiple + let mclk_multiple = if data_bits == 24 { 192 } else { 256 }; let sclk = 160_000_000; // for now it's fixed PLL_160M_CLK let rate_hz: HertzU32 = sample_rate.into();