I2S Microphone ESP32

Standart I2S (INMP441):

i2s_port_t m_i2sPort = I2S_NUM_0;

// i2s config for reading from left channel of I2S

i2s_config_t i2sMemsConfigLeftChannel = {

    .mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX),

    .sample_rate = 16000,

    .bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT,

    .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,

    .communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_I2S),

    .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,

    .dma_buf_count = 4,

    .dma_buf_len = 1024,

    .use_apll = false,

    .tx_desc_auto_clear = false,

    .fixed_mclk = 0};

MSB justified + Falling edge data sampling (SPH0645):

Fix 1:

//Set to Left MSB justified

.communication_format = I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB,

For idf >=5

Change I2S_STD_PHILIP_SLOT_DEFAULT_CONFIG to I2S_STD_MSB_SLOT_DEFAULT_CONFIG

//or modify register by:

REG_SET_BIT(I2S_CONF_REG(m_i2sPort), I2S_RX_MSB_SHIFT);

Fix 2:

//Set to delay sampling time at falling edge(neg edge)

REG_SET_BIT(I2S_TIMING_REG(m_i2sPort), BIT(9)); // [9:8] –> I2S_RX_SD_IN_DELAY  

/*

The I2S_RX_SD_IN_DELAY parameter is used to configure the delay mode of the I2S (Inter-IC Sound) RX SD input signal. The delay mode of I2S Rx SD input signal. 0: bypass. 1: delay by pos edge. 2: delay by neg edge. 3: not used

*/