Author Topic: ESP32 as I2S (Audio) slave  (Read 2698 times)

0 Members and 1 Guest are viewing this topic.

Offline jmibkTopic starter

  • Regular Contributor
  • *
  • Posts: 68
  • Country: at
ESP32 as I2S (Audio) slave
« on: May 26, 2022, 07:15:55 pm »
I'm trying to use the ESP32 as a simple bluetooth audio receiver that is connected to an ADAU1701 DSP via I2S.
The ESP32 works perfectly on the PCM5102 DAC when the ESP32 is running in Master Mode ( .mode = (i2s_mode_t) (I2S_MODE_MASTER | I2S_MODE_TX) )
So, every pin spits out the correct signals.

Now my problem is, that the DSP acts as a master and the ESP32 should receive the main clock from the DSP.
With the following code I have following signals on its pins (bluetooth device is connected and streaming audio):
Pin3, Masterclock: 11,28MHz
Pin13, I2S Data: no signal
Pin14, LRCK: 48kHz (coming from the DSP, MP10, LRCK OUT)
Pin15, BitClock: 3,07MHz (coming from the DSP, MP11, BCK OUT)

Someone is running such configuration and knows how to configure that thing?

BT Library used: https://www.pschatzmann.ch/home/2020/03/27/1255/
Board used: Olimex ESP32-PoE

Code: [Select]
#include "BluetoothA2DPSink.h"

BluetoothA2DPSink a2dp_sink;

void setup() {
  static const i2s_config_t i2s_config = {
    .mode = (i2s_mode_t) (I2S_MODE_SLAVE | I2S_MODE_TX),
    .sample_rate = 48000, // corrected by info from bluetooth
    .bits_per_sample = (i2s_bits_per_sample_t) 16, /* the DAC module will only take the 8bits from MSB */
    .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
    .communication_format = I2S_COMM_FORMAT_I2S_MSB,
    .intr_alloc_flags = 0, // default interrupt priority
    .dma_buf_count = 8,
    .dma_buf_len = 64,
    .use_apll = false
    };
  a2dp_sink.set_i2s_config(i2s_config);

  static const i2s_pin_config_t pin_config = {
    //.mck_io_num = 3,
    .bck_io_num = 15,
    .ws_io_num = 14,
    .data_out_num = 13,
    .data_in_num = I2S_PIN_NO_CHANGE
    };

  a2dp_sink.set_pin_config(pin_config);

  a2dp_sink.i2s_mclk_pin_select(3);
  a2dp_sink.start("MyMusic", true); 
  }

void loop() {
  delay(1000); // do nothing
  }
 

Offline zsoltyfm

  • Newbie
  • Posts: 3
  • Country: hu
Re: ESP32 as I2S (Audio) slave
« Reply #1 on: June 26, 2022, 02:45:18 pm »
HI!
The ESP32 must be the master and the DSP the slave! Perhaps an ADAU1452 would be more suitable for this task because it contains ASRCs and thus can process multiple master sources properly at the same time.
 

Offline fmsndx

  • Newbie
  • Posts: 1
  • Country: de
Re: ESP32 as I2S (Audio) slave
« Reply #2 on: September 07, 2022, 04:00:49 pm »
Hey,

got the same problem with a simliar setup. I don't get it working when the ESP32 is the Master. When the ADAU1701 is the Master, I can stream audio via A2DP over I2S on the DSP and over analog to a headphone. But the problem is, that the audio is pitched. I think there is a problem in some of the CLOCKs (maybe BCLK?). I tried a lot of diffrent configuration in ESP with the library from pschatzmann or the DSP with SigmaStudio.

My Current best working Config is:
Code: [Select]
  static const i2s_config_t i2s_config = {
      .mode = (i2s_mode_t)(I2S_MODE_SLAVE | I2S_MODE_TX),
      .sample_rate = 44100, // corrected by info from bluetooth
      .bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT,
      .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
      .communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_I2S_MSB | I2S_COMM_FORMAT_I2S),
      .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
      .dma_buf_count = 8,
      .dma_buf_len = 256,
      .use_apll = false,
      .tx_desc_auto_clear = true};
* sigmastudio_hardwareconfig.png (270.29 kB. 1102x774 - viewed 229 times.)


Did you fixed it @zsoltyfm?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf