esp-idf icon indicating copy to clipboard operation
esp-idf copied to clipboard

I2S Slave mode does NOT work (IDFGH-13042)

Open mrx23dot opened this issue 1 year ago • 2 comments

Answers checklist.

  • [X] I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • [X] I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • [X] I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

I set up ESP32 as I2S slave, input signals are valid, but i2s_channel_read always times out, ie not receiving. Master mode works.

  i2s_chan_config_t chan_cfg = I2S_CHANNEL_DEFAULT_CONFIG(I2S_NUM_AUTO, I2S_ROLE_SLAVE);
  ESP_ERROR_CHECK(i2s_new_channel(&chan_cfg, &chTx, &chRx)); 
  
  i2s_std_config_t std_cfg = {
    .clk_cfg = I2S_STD_CLK_DEFAULT_CONFIG(441000), /* even for slave? */
    .slot_cfg = I2S_STD_PHILIPS_SLOT_DEFAULT_CONFIG(I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_STEREO),
    .gpio_cfg = {
    
      .mclk = I2S_GPIO_UNUSED, 
      .bclk = GPIO_NUM_17,
      .ws = GPIO_NUM_5,
      .dout = I2S_GPIO_UNUSED, 
      .din = GPIO_NUM_26,

      .invert_flags = {
        .mclk_inv = false,
        .bclk_inv = false,
        .ws_inv = false,
      },
    },
  };

  /* Initialize the channels */
  ESP_ERROR_CHECK(i2s_channel_init_std_mode(chTx, &std_cfg));
  ESP_ERROR_CHECK(i2s_channel_init_std_mode(chRx, &std_cfg));

  /* not doing i2s_channel_preload_data on tx buf */
  ESP_ERROR_CHECK(i2s_channel_enable(chTx));
  ESP_ERROR_CHECK(i2s_channel_enable(chRx)); /* both needed for multiplex */

  // always returns timeout
  res = i2s_channel_read(chRx, r_buf, 40, &readBytes, 1000);

Prove me wrong with a working example.

env

    Module or chip used: ESP32-WROOM-32
   I (29) boot: ESP-IDF v5.4-dev-421-g4523f2d674 2nd stage bootloader
    Build System: docker
    Operating System: Linux

mrx23dot avatar Jun 15 '24 19:06 mrx23dot

others also having issues https://github.com/espressif/esp-idf/issues/9123

mrx23dot avatar Jun 15 '24 19:06 mrx23dot

Hi @mrx23dot

Image

Seems additional 0 in the sample rate? I guess you mean 44100 Hz right?

L-KAYA avatar Jun 18 '25 09:06 L-KAYA

You might be right. Would be nice if API caught this.

mrx23dot avatar Aug 06 '25 21:08 mrx23dot