I2S: Read in slavemode timeout

dbultra
Posts: 1
Joined: Fri Jun 13, 2025 8:00 am

I2S: Read in slavemode timeout

Postby dbultra » Fri Jun 13, 2025 9:30 am

Hi,
I'm using an ESP32-PICO-MINI-02 as I2S-Receiver in slave mode. On the other end there is an ESP32-S3 sending data as I2S-Transmitter in master mode. The transmission is correctly, because there is a second participant (an I2S-Amp) listening, working just fine. I am using esp-idf 5.5.
Sadly the i2s_channel_read function runs into a timeout.
Has anybody solved this kind of problem or got any suggestions?
I already tried to connect the mclk lane, changing the pins and so on, but it does not change anything. Still no correct reading just a timeout.

Here some code for prober investigations:

Code: Select all

    	i2s_chan_config_t chan_cfg = I2S_CHANNEL_DEFAULT_CONFIG(I2S_NUM_AUTO, I2S_ROLE_SLAVE);
	/* Allocate a new RX channel and get the handle of this channel */
	i2s_new_channel(&chan_cfg, NULL, &rx_handle);
	
	/* Setting the configurations, the slot configuration and clock configuration can be generated by the macros
	 * These two helper macros are defined in `i2s_std.h` which can only be used in STD mode.
	 * They can help to specify the slot and clock configurations for initialization or updating */
	i2s_std_config_t std_cfg = {
	    .clk_cfg = I2S_STD_CLK_DEFAULT_CONFIG(44100),
	    .slot_cfg = I2S_STD_MSB_SLOT_DEFAULT_CONFIG(I2S_DATA_BIT_WIDTH_8BIT, I2S_SLOT_MODE_STEREO),
	    .gpio_cfg = {
	        .mclk = GPIO_NUM_NC,
	        .bclk = PIN_NUM_BCLK,
	        .ws = PIN_NUM_WS,
	        .dout = GPIO_NUM_NC,
	        .din = PIN_NUM_DIN,
	        .invert_flags = {
	            .mclk_inv = false,
	            .bclk_inv = false,
	            .ws_inv = false,
	        },
	    },
	};
	
	/* Initialize the channel */
	i2s_channel_init_std_mode(rx_handle, &std_cfg);
	/* Task where i2s_read() is called */
   	xTaskCreatePinnedToCore(i2s_listen_task, "read", 8*1024, NULL, 8, NULL, 1);

Code: Select all

/* Callback were i2s_read() writes into a buffer */
static void i2s_listen_task(void *param)
{
	i2s_channel_enable(rx_handle);
	size_t bytes_read = 0;
	int w_index = 0;
	for(;;) {
		if(i2s_channel_read(rx_handle, AUDIO_BUFFER[w_index], AUD_BUF_SIZE, &bytes_read,  1000) == ESP_ERR_TIMEOUT )
		{
			ESP_LOGE("I2S", "TIMEOUT WHILE READING");
		}
	}
}
Thanks.

Who is online

Users browsing this forum: ChatGPT-User, PerplexityBot and 2 guests