ESP32-S3 I2S APLL无法启用
Posted: Fri Apr 01, 2022 4:09 pm
想请教大家一下ESP32-S3在APLL 无法启用的情况下该如何正确配置I2S总线上的MEMS麦克风的参数,比如i2s_config 和i2s_set_clk。下面是我自己的代码但是无法正确运行。非常感谢!
- #define CONFIG_I2S_CH I2S_NUM_0
- #define CONFIG_SAMPLE_RATE 48000
- #define CONFIG_BIT_SAMPLE 32 //bits
- #define SAMPLE_T int32_t
- #define CONFIG_SAMPLES_SHORT (CONFIG_SAMPLE_RATE / 8) // ~125ms 6000
- #define CONFIG_SAMPLE_T int32_t
- #define CONFIG_SAMPLES_LEQ (CONFIG_SAMPLE_RATE * LEQ_PERIOD)
- #define CONFIG_DMA_BANK_SIZE (CONFIG_SAMPLES_SHORT / 16) //375
- #define CONFIG_DMA_BANKS 32
- #define CONFIG_I2S_WS_GPIO 4
- #define CONFIG_I2S_CLK_GPIO 5
- #define CONFIG_I2S_SD 13
- extern "C" void init_microphone(void)
- {
- // Set the I2S configuration as PDM and 32bits per sample
- i2s_config_t i2s_config = {
- mode :i2s_mode_t(I2S_MODE_MASTER| I2S_MODE_RX),
- .sample_rate = CONFIG_SAMPLE_RATE,
- .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 | I2S_COMM_FORMAT_I2S_MSB),
- .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
- .dma_buf_count = CONFIG_DMA_BANKS,
- .dma_buf_len = CONFIG_DMA_BANK_SIZE,
- .use_apll = 0,
- tx_desc_auto_clear: true,
- fixed_mclk: 0,
- };
- // Set the pinout configuration (set using menuconfig)
- i2s_pin_config_t pin_config = {
- .bck_io_num = CONFIG_I2S_CLK_GPIO,
- .ws_io_num = CONFIG_I2S_WS_GPIO,
- .data_out_num = I2S_PIN_NO_CHANGE,
- .data_in_num = CONFIG_I2S_SD,
- };
- // Call driver installation function before any I2S R/W operation.
- ESP_ERROR_CHECK( i2s_driver_install(CONFIG_I2S_CH, &i2s_config, 0, NULL) );
- ESP_ERROR_CHECK( i2s_set_pin(CONFIG_I2S_CH, &pin_config) );
- ESP_ERROR_CHECK( i2s_set_clk(CONFIG_I2S_CH, CONFIG_SAMPLE_RATE, I2S_BITS_PER_SAMPLE_32BIT, I2S_CHANNEL_MONO) );
- }