ESP32-S3 I2S APLL无法启用

Moderator: ESP_Bob

Wenjing
Posts: 4
Joined: Mon Mar 21, 2022 12:44 pm

ESP32-S3 I2S APLL无法启用

Postby Wenjing » Fri Apr 01, 2022 4:09 pm

想请教大家一下ESP32-S3在APLL 无法启用的情况下该如何正确配置I2S总线上的MEMS麦克风的参数,比如i2s_config 和i2s_set_clk。下面是我自己的代码但是无法正确运行。非常感谢!
  1.  
  2. #define CONFIG_I2S_CH             I2S_NUM_0
  3. #define CONFIG_SAMPLE_RATE        48000
  4. #define CONFIG_BIT_SAMPLE         32 //bits
  5. #define SAMPLE_T                  int32_t
  6. #define CONFIG_SAMPLES_SHORT     (CONFIG_SAMPLE_RATE / 8) // ~125ms 6000
  7.  
  8. #define CONFIG_SAMPLE_T          int32_t
  9. #define CONFIG_SAMPLES_LEQ       (CONFIG_SAMPLE_RATE * LEQ_PERIOD)
  10. #define CONFIG_DMA_BANK_SIZE     (CONFIG_SAMPLES_SHORT / 16) //375
  11. #define CONFIG_DMA_BANKS         32
  12.  
  13. #define CONFIG_I2S_WS_GPIO 4
  14. #define CONFIG_I2S_CLK_GPIO 5
  15. #define CONFIG_I2S_SD 13
  16.  
  17. extern "C" void init_microphone(void)
  18. {
  19.     // Set the I2S configuration as PDM and 32bits per sample
  20.     i2s_config_t i2s_config = {
  21.        
  22.         mode :i2s_mode_t(I2S_MODE_MASTER| I2S_MODE_RX),
  23.         .sample_rate = CONFIG_SAMPLE_RATE,
  24.         .bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT,
  25.         .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
  26.         communication_format: i2s_comm_format_t(I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB),
  27.         .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
  28.         .dma_buf_count = CONFIG_DMA_BANKS,
  29.         .dma_buf_len = CONFIG_DMA_BANK_SIZE,
  30.         .use_apll = 0,
  31.         tx_desc_auto_clear: true,
  32.         fixed_mclk: 0,
  33.     };
  34.  
  35.     // Set the pinout configuration (set using menuconfig)
  36.     i2s_pin_config_t pin_config = {
  37.      
  38.         .bck_io_num = CONFIG_I2S_CLK_GPIO,
  39.         .ws_io_num = CONFIG_I2S_WS_GPIO,
  40.         .data_out_num = I2S_PIN_NO_CHANGE,
  41.         .data_in_num = CONFIG_I2S_SD,
  42.     };
  43.  
  44.    
  45.     // Call driver installation function before any I2S R/W operation.
  46.    
  47.     ESP_ERROR_CHECK( i2s_driver_install(CONFIG_I2S_CH, &i2s_config, 0, NULL) );
  48.     ESP_ERROR_CHECK( i2s_set_pin(CONFIG_I2S_CH, &pin_config) );
  49.     ESP_ERROR_CHECK( i2s_set_clk(CONFIG_I2S_CH, CONFIG_SAMPLE_RATE, I2S_BITS_PER_SAMPLE_32BIT, I2S_CHANNEL_MONO) );
  50. }

kaisey
Posts: 81
Joined: Tue Mar 24, 2020 5:54 am

Re: ESP32-S3 I2S APLL无法启用

Postby kaisey » Sat Apr 02, 2022 2:36 am

你为什么要用APLL呢

Wenjing
Posts: 4
Joined: Mon Mar 21, 2022 12:44 pm

Re: ESP32-S3 I2S APLL无法启用

Postby Wenjing » Mon Apr 04, 2022 12:07 pm

因为我不是很会配置sck和ws和ESP32的采样频率这些参数,然后就想用APLL会省事一些。我也参考了一些ESP32的库也是用的APLL,比如这个: https://github.com/ikostoski/esp32-i2s- ... 2s-slm.ino

Wenjing
Posts: 4
Joined: Mon Mar 21, 2022 12:44 pm

Re: ESP32-S3 I2S APLL无法启用

Postby Wenjing » Mon Apr 04, 2022 3:34 pm

<r>问题解决了,是我自己硬件线路接错了。。。抱歉占用了站里的资源
<CODEBOX codebox="c" file="Untitled.c"><s>
  1. </s>
  2. extern "C" void init_microphone(void)<br/>
  3. {<br/>
  4.     <br/>
  5.     i2s_config_t i2s_config = {<br/>
  6.        <br/>
  7.         mode :i2s_mode_t(I2S_MODE_MASTER| I2S_MODE_RX),<br/>
  8.         .sample_rate = CONFIG_SAMPLE_RATE,<br/>
  9.         .bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT,<br/>
  10.         .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,<br/>
  11.         .communication_format = I2S_COMM_FORMAT_STAND_I2S,<br/>
  12.         .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,<br/>
  13.         .dma_buf_count = CONFIG_DMA_BANKS,<br/>
  14.         .dma_buf_len = CONFIG_DMA_BANK_SIZE,<br/>
  15.         .use_apll = 1,<br/>
  16.         tx_desc_auto_clear: true,<br/>
  17.         .fixed_mclk = 0,<br/>
  18.     };<br/>
  19. <br/>
  20.     // Set the pinout configuration<br/>
  21.     i2s_pin_config_t pin_config = {<br/>
  22.       <br/>
  23.         .bck_io_num = CONFIG_I2S_CLK_GPIO,<br/>
  24.         .ws_io_num = CONFIG_I2S_WS_GPIO,<br/>
  25.         .data_out_num = I2S_PIN_NO_CHANGE,<br/>
  26.         .data_in_num = CONFIG_I2S_SD,<br/>
  27.     };<br/>
  28. <br/>
  29.     <br/>
  30.     // Call driver installation function before any I2S R/W operation.<br/>
  31.     <br/>
  32.     ESP_ERROR_CHECK( i2s_driver_install(CONFIG_I2S_CH, &i2s_config, 0, NULL) );<br/>
  33.     ESP_ERROR_CHECK( i2s_set_pin(CONFIG_I2S_CH, &pin_config) );<e>
</e></CODEBOX></r>

kaisey
Posts: 81
Joined: Tue Mar 24, 2020 5:54 am

Re: ESP32-S3 I2S APLL无法启用

Postby kaisey » Thu Apr 21, 2022 12:47 am

ESP32-S3没有APLL吧,数据手册里都写了没有APLL,

Who is online

Users browsing this forum: No registered users and 7 guests