I2S - can wroom be slave and receive pcm data?

colinz
Posts: 1
Joined: Thu Jun 20, 2024 12:00 pm

I2S - can wroom be slave and receive pcm data?

Postby colinz » Thu Jun 20, 2024 12:20 pm

I'm new to I2S and there is not much information about how to set it as slave and receive pcm data. What i've tried is two esp32 S3-wroom as i2s master and slave based on the official I2S example > FullDuplex, if i change the communication_format to I2S_COMM_FORMAT_I2S, the slave's serial will print a serials of "0", its not what i sent but it's another problem. But if i change both master and slave to I2S_COMM_FORMAT_STAND_PCM_SHORT, the slave will not print at all. Is there other thing i need to do to receive PCM data? I only wired bck, ws, and data in or out three lines, the mclk is floating. The slave code is like:
  1. #include "driver/i2s.h"
  2.  
  3. i2s_config_t i2s_config = {
  4.   .mode = (i2s_mode_t)(I2S_MODE_SLAVE | I2S_MODE_TX | I2S_MODE_RX),
  5.   .sample_rate = 8000,
  6.   .bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
  7.   .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
  8.   .communication_format = I2S_COMM_FORMAT_STAND_PCM_SHORT,
  9.   .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
  10.   .dma_buf_count = 8,
  11.   .dma_buf_len = 256,
  12.   .use_apll = true,
  13. };
  14.  
  15. i2s_pin_config_t pin_config = {
  16.   .bck_io_num = 4,
  17.   .ws_io_num = 5,
  18.   .data_out_num = 7,
  19.   .data_in_num = 6
  20. };
  21.  
  22. uint16_t rxbuf[256];
  23. size_t readsize = 0;
  24.  
  25. void setup(){
  26.   i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);
  27.   i2s_set_pin(I2S_NUM_0, &pin_config);
  28.   Serial.begin(115200);
  29. }
  30.  
  31. void loop(){
  32.   readsize=0;
  33.   i2s_read(I2S_NUM_0, &rxbuf[0], 3, &readsize, 100);
  34.   if(readsize > 0){
  35.     for(int i = 0; i < readsize; i++){
  36.       Serial.print(rxbuf[i]);
  37.       Serial.print(" ");
  38.     }
  39.     Serial.println();
  40.   }
  41. }

Who is online

Users browsing this forum: No registered users and 100 guests