Search code examples
caudioembeddedaudio-recordingesp32

Configuring audio codec on Espressif ESP32-LYRATD-MSC Development Board


When I compile and flash an ESP32-LYRATD-MSC with the official audio recording examples, I get an es_write_reg error after configuring the ES8388 codec driver.

What could have changed from the LYRA or WROVER kits to the LYRATD-MSC that could cause the error?


Solution

  • This is a known issue with the samples. The ESP32-LYRATD-MSC ships with the ZL38063 DSP chip, but as you can see from sample, it expects to configure the ESP8388:

    audio_hal_codec_config_t audio_hal_codec_cfg =  AUDIO_HAL_ES8388_DEFAULT(); // offending line
    audio_hal_codec_cfg.i2s_iface.samples = AUDIO_HAL_16K_SAMPLES;
    audio_hal_handle_t hal = audio_hal_init(&audio_hal_codec_cfg, 0);
    audio_hal_ctrl_codec(hal, AUDIO_HAL_CODEC_MODE_ENCODE, AUDIO_HAL_CTRL_START);
    

    To resolve, configure for the ZL38063 instead:

    audio_hal_handle_t init_audio_codec()
    {
    #if (CONFIG_ESP_LYRAT_V4_3_BOARD || CONFIG_ESP_LYRAT_V4_2_BOARD)
        audio_hal_codec_config_t audio_hal_codec_cfg = AUDIO_HAL_ES8388_DEFAULT();
        return audio_hal_init(&audio_hal_codec_cfg, 0);
    #endif
    
    #if (CONFIG_ESP_LYRATD_MSC_V2_1_BOARD || CONFIG_ESP_LYRATD_MSC_V2_2_BOARD)
        audio_hal_codec_config_t audio_hal_codec_cfg = AUDIO_HAL_ZL38063_DEFAULT();
        return audio_hal_init(&audio_hal_codec_cfg, 2);
    #endif
    }
    

    Then, in app_main():

    audio_hal_ctrl_codec(init_audio_codec(), AUDIO_HAL_CODEC_MODE_BOTH, AUDIO_HAL_CTRL_START);