ADAU7002 I2S ESP32-S3

plasmaphase
Posts: 4
Joined: Sun Jan 15, 2023 12:57 am

ADAU7002 I2S ESP32-S3

Postby plasmaphase » Sun Jan 22, 2023 10:25 pm

I'm trying to get valid audio data using an ESP32-S3 and the IM69D130 Microphone Audio Shield2Go Platform Evaluation Expansion Board (https://www.infineon.com/dgdl/Infineon- ... 3486ed0941). This board has two IM69D130 microphones and runs those both through an ADAU7002 device (https://www.analog.com/media/en/technic ... AU7002.pdf). On this particular dev board, it's configured to be I2S mode (CONFIG pin tied to VDD), and according to the datasheet, it should be 20 bits of PCM audio:

appnote.png
appnote.png (207.81 KiB) Viewed 1563 times

It's not clear to me whether this means the output over I2S will be 20-bit stereo, but that's my assumption. The waveform of the ADAU7002 in I2S mode is shown below:

waveform.png
waveform.png (24.11 KiB) Viewed 1563 times

There is no "I2S_DATA_BIT_WIDTH_20BIT", so I'm not sure how to configure I2S to properly acquire data. I am able to receive a stream of data, so I2S is at least functional and pinouts seem good, but it's not yet what I'd consider valid audio (I cannot make out any noise being made). I've configured the ESP32-S3 as follows:

Code: Select all

    i2s_chan_config_t rx_chan_cfg = I2S_CHANNEL_DEFAULT_CONFIG(I2S_NUM_AUTO, I2S_ROLE_MASTER);
    ESP_ERROR_CHECK(i2s_new_channel(&rx_chan_cfg, NULL, &rx_chan));

    i2s_std_clk_config_t clk_cfg = {
        .clk_src = I2S_CLK_SRC_DEFAULT,
        .sample_rate_hz = 16000,
        .mclk_multiple = I2S_MCLK_MULTIPLE_512};

    i2s_std_slot_config_t slot_cfg = {
        .data_bit_width = I2S_DATA_BIT_WIDTH_24BIT,
        .slot_bit_width = I2S_SLOT_BIT_WIDTH_AUTO,
        .slot_mode = I2S_SLOT_MODE_STEREO,
        .slot_mask = I2S_STD_SLOT_BOTH,
        .ws_width = I2S_DATA_BIT_WIDTH_24BIT,
        .ws_pol = false,
        .bit_shift = true,
        .left_align = false,
        .big_endian = false,
        .bit_order_lsb = false};

    i2s_std_config_t rx_std_cfg = {
        .clk_cfg = clk_cfg,
        .slot_cfg = slot_cfg,
        .gpio_cfg = {
            .mclk = I2S_GPIO_UNUSED, // some codecs may require mclk signal, this example doesn't need it
            .bclk = I2S_BCLK,
            .ws = I2S_WS,
            .dout = I2S_GPIO_UNUSED,
            .din = I2S_DIN,
            .invert_flags = {
                .mclk_inv = false,
                .bclk_inv = false,
                .ws_inv = false,
            },
        },
    };

    rx_std_cfg.slot_cfg.slot_mask = I2S_STD_SLOT_BOTH;
    ESP_ERROR_CHECK(i2s_channel_init_std_mode(rx_chan, &rx_std_cfg));
I've also tried setting .data_bit_width to 20, as well as .ws_width, and it certainly compiles and runs, but I'm still not able to get good data. Just a note, I have set .bit_shift to TRUE as I am relatively certain that needs to be done. Has anyone had any experience with utilizing the ADAU7002 with an ESP32? Any tips on how to configure the I2S channel?

Right now I'm taking this data, in 2048 byte chunks, and placing them in a .wav file, pushed to an SD Card. Data capture seems to work great, and I'm pretty sure I have the wave file setup correctly. Now it's a matter of understanding how to configure the data acquisition such that it's aligned with the part, as I'm not sure that's correct.

plasmaphase
Posts: 4
Joined: Sun Jan 15, 2023 12:57 am

Re: ADAU7002 I2S ESP32-S3

Postby plasmaphase » Sat Jan 28, 2023 4:20 pm

Well, I was able to get audio, but it's extremely quiet. My updated settings are:

Code: Select all

	typedef enum
	{
		SR_8K = 8000,
		SR_11K = 11025,
		SR_16K = 16000,
		SR_22K = 22050,
		SR_44K = 44100,
		SR_48K = 48000,
		SR_88K = 88200,
		SR_96K = 96000,
		SR_176K = 176400,
		SR_192K = 192000,
		SR_352K = 352800,
		SR_384K = 384000
	} sampleRate_t;

	// Used to fill in the bitDepth field
	typedef enum
	{
		BD_8 = 8,
		BD_16 = 16,
		BD_20 = 20,
		BD_24 = 24,
		BD_32 = 32
	} bitDepth_t;

    #define EXAMPLE_BUFF_SIZE 4096
    #define SAMPLE_RATE SR_44K
    #define BIT_WIDTH BD_20    
    i2s_chan_config_t rx_chan_cfg = I2S_CHANNEL_DEFAULT_CONFIG(I2S_NUM_AUTO, I2S_ROLE_MASTER);
    ESP_ERROR_CHECK(i2s_new_channel(&rx_chan_cfg, NULL, &rx_chan));

    i2s_std_clk_config_t clk_cfg = {
        .clk_src = I2S_CLK_SRC_DEFAULT,
        .sample_rate_hz = SAMPLE_RATE,
        .mclk_multiple = I2S_MCLK_MULTIPLE_384};

    i2s_std_slot_config_t slot_cfg = {
        .data_bit_width = BIT_WIDTH,
        .slot_bit_width = I2S_SLOT_BIT_WIDTH_AUTO,
        .slot_mode = I2S_SLOT_MODE_STEREO,
        .slot_mask = I2S_STD_SLOT_BOTH,
        .ws_width = I2S_DATA_BIT_WIDTH_32BIT,
        .ws_pol = false,
        .bit_shift = true,
        .left_align = false,
        .big_endian = false,
        .bit_order_lsb = false};

    i2s_std_config_t rx_std_cfg = {
        .clk_cfg = clk_cfg,
        .slot_cfg = slot_cfg,
        .gpio_cfg = {
            .mclk = I2S_GPIO_UNUSED,
            .bclk = I2S_BCLK,
            .ws = I2S_WS,
            .dout = I2S_GPIO_UNUSED,
            .din = I2S_DIN,
            .invert_flags = {
                .mclk_inv = false,
                .bclk_inv = false,
                .ws_inv = false,
            },
        },
    };

    rx_std_cfg.slot_cfg.slot_mask = I2S_STD_SLOT_BOTH;
    ESP_ERROR_CHECK(i2s_channel_init_std_mode(rx_chan, &rx_std_cfg));

The resultant wav file, when opened looks like:
quiet.png
quiet.png (12.51 KiB) Viewed 1489 times

It doesn't look like much, but when I amplify the audio (40dB...yes, it's a lot), I can clearly hear my finger snaps and other testing audio quite clearly.
amplified.png
amplified.png (16.66 KiB) Viewed 1489 times

So now I'm trying to figure out why this audio is so quiet... It's unclear if this is an issue with how I'm capturing I2S from the ADAU7002, or if that board need amplification, or maybe a setting in the ESP32-S3?

superware
Posts: 1
Joined: Mon Jun 17, 2024 10:32 pm

Re: ADAU7002 I2S ESP32-S3

Postby superware » Mon Jun 17, 2024 10:38 pm

Hello plasmaphase,
plasmaphase wrote:
Sat Jan 28, 2023 4:20 pm
Well, I was able to get audio, but it's extremely quiet.

Have you managed with the amplitude level? Can you please post the entire code? I'm having trouble extracting each channel (left/right) 20-bit from i2s_channel_read output buffer.

Thank you in advance!

Who is online

Users browsing this forum: No registered users and 105 guests