From c35eb827249f21fcb62072461f61952cf0ca7965 Mon Sep 17 00:00:00 2001 From: Chen Chen Date: Sat, 9 May 2026 15:14:13 +0800 Subject: [PATCH] docs(i2s): add note for the restriction of MCLK on esp32 Closes https://github.com/espressif/esp-idf/issues/18564 --- components/esp_driver_i2s/i2s_common.c | 2 +- docs/en/api-reference/peripherals/i2s.rst | 6 ++++++ docs/zh_CN/api-reference/peripherals/i2s.rst | 6 ++++++ examples/peripherals/i2c/i2c_basic/README.md | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/components/esp_driver_i2s/i2s_common.c b/components/esp_driver_i2s/i2s_common.c index 54f033889a1..e237b1750f2 100644 --- a/components/esp_driver_i2s/i2s_common.c +++ b/components/esp_driver_i2s/i2s_common.c @@ -953,7 +953,7 @@ esp_err_t i2s_check_set_mclk(i2s_chan_handle_t handle, int id, int gpio_num, i2s if (g_i2s.controller[id]->mclk_out_hdl == NULL) { i2s_output_gpio_reserve(handle, gpio_num); soc_clkout_sig_id_t clkout_sig = is_apll ? CLKOUT_SIG_APLL : (is_i2s0 ? CLKOUT_SIG_I2S0 : CLKOUT_SIG_I2S1); - ESP_RETURN_ON_ERROR(esp_clock_output_start(clkout_sig, gpio_num, &(g_i2s.controller[id]->mclk_out_hdl)), TAG, "mclk configure failed"); + ESP_RETURN_ON_ERROR(esp_clock_output_start(clkout_sig, gpio_num, &(g_i2s.controller[id]->mclk_out_hdl)), TAG, "mclk configure failed, note: only gpio 0/1/3 are supported on esp32"); } #else ESP_RETURN_ON_FALSE(GPIO_IS_VALID_GPIO(gpio_num), ESP_ERR_INVALID_ARG, TAG, "mck_io_num invalid"); diff --git a/docs/en/api-reference/peripherals/i2s.rst b/docs/en/api-reference/peripherals/i2s.rst index b3fe2e8660d..3df795038f3 100644 --- a/docs/en/api-reference/peripherals/i2s.rst +++ b/docs/en/api-reference/peripherals/i2s.rst @@ -75,6 +75,12 @@ Clock Terminology Normally, MCLK should be the multiple of ``sample rate`` and BCLK at the same time. The field :cpp:member:`i2s_std_clk_config_t::mclk_multiple` indicates the multiple of MCLK to the ``sample rate``. In most cases, ``I2S_MCLK_MULTIPLE_256`` should be enough. However, if ``slot_bit_width`` is set to ``I2S_SLOT_BIT_WIDTH_24BIT``, to keep MCLK a multiple to the BCLK, :cpp:member:`i2s_std_clk_config_t::mclk_multiple` should be set to multiples that are divisible by 3 such as ``I2S_MCLK_MULTIPLE_384``. Otherwise, WS will be inaccurate. +.. only:: esp32 + + .. note:: + + On ESP32, the MCLK pin must use GPIO0, GPIO1, or GPIO3. The other clock pins (e.g., BCLK, WS) can use any valid GPIO. Note that GPIO0 is generally not recommended for other functions because it is a strapping pin. + .. _i2s-communication-mode: I2S Communication Mode diff --git a/docs/zh_CN/api-reference/peripherals/i2s.rst b/docs/zh_CN/api-reference/peripherals/i2s.rst index 3d24d844570..1266f731ae6 100644 --- a/docs/zh_CN/api-reference/peripherals/i2s.rst +++ b/docs/zh_CN/api-reference/peripherals/i2s.rst @@ -75,6 +75,12 @@ I2S 时钟 通常,MCLK 应该同时是 ``采样率`` 和 BCLK 的倍数。字段 :cpp:member:`i2s_std_clk_config_t::mclk_multiple` 表示 MCLK 相对于 ``采样率`` 的倍数。在大多数情况下,将其设置为 ``I2S_MCLK_MULTIPLE_256`` 即可。但如果 ``slot_bit_width`` 被设置为 ``I2S_SLOT_BIT_WIDTH_24BIT``,为了保证 MCLK 是 BCLK 的整数倍,应该将 :cpp:member:`i2s_std_clk_config_t::mclk_multiple` 设置为能被 3 整除的倍数,如 ``I2S_MCLK_MULTIPLE_384``,否则 WS 会不精准。 +.. only:: esp32 + + .. note:: + + 在ESP32上,MCLK 管脚必须使用 GPIO0、GPIO1 或 GPIO3 管脚。其他的时钟管脚可以使用任意的 GPIO。注意,由于 GPIO0 为 Strapping 管脚,一般不推荐用作其他功能。 + .. _i2s-communication-mode: I2S 通信模式 diff --git a/examples/peripherals/i2c/i2c_basic/README.md b/examples/peripherals/i2c/i2c_basic/README.md index 4ae7c6ff080..8aa2d3cf750 100644 --- a/examples/peripherals/i2c/i2c_basic/README.md +++ b/examples/peripherals/i2c/i2c_basic/README.md @@ -15,7 +15,7 @@ If you have a new I2C application to go (for example, read the temperature data ### Hardware Required -To run this example, you should have an Espressif development board based on a chip listed in supported targets as well as a MPU9250. MPU9250 is a inertial measurement unit, which contains a accelerometer, gyroscope as well as a magnetometer, for more information about it, you can read the [datasheet of the MPU9250 sensor](https://invensense.tdk.com/wp-content/uploads/2015/02/PS-MPU-9250A-01-v1.1.pdf). +To run this example, you should have an Espressif development board based on a chip listed in supported targets as well as a MPU9250. MPU9250 is a inertial measurement unit, which contains a accelerometer, gyroscope as well as a magnetometer, for more information about it, you can read the [datasheet of the MPU9250 sensor](https://download.mikroe.com/documents/datasheets/PS-MPU-9250A-01-v1.1.pdf). #### Pin Assignment