目前我們再操作PDM麥克風的時候,我們量到clk是2.6~2.9MHz在變化
這是初始化設定的部分程式碼。
Code: Select all
//i2s number
#define I2S_NUM (0)
//i2s sample rate
#define I2S_SAMPLE_RATE (44100)
//i2s data bits
#define I2S_SAMPLE_BITS (16)
//I2S read buffer length
#define I2S_READ_LEN ((I2S_SAMPLE_BITS / 8) * 1024)
//I2S data format
#define I2S_FORMAT (I2S_CHANNEL_FMT_ONLY_RIGHT)
//I2S channel number
#define I2S_CHANNEL_NUM ((I2S_FORMAT < I2S_CHANNEL_FMT_ONLY_RIGHT) ? (2) : (1))
i2s_config_t i2s_config = {
.mode = I2S_MODE_MASTER | I2S_MODE_RX | I2S_MODE_PDM,
.sample_rate = I2S_SAMPLE_RATE,
.bits_per_sample = I2S_SAMPLE_BITS,
.communication_format = I2S_COMM_FORMAT_PCM,
.channel_format = I2S_FORMAT,
.dma_buf_count = 32,
.dma_buf_len = 64,
.use_apll = true,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1
};
i2s_pin_config_t pin_config = {
.bck_io_num = -1,
.ws_io_num = 21,
.data_out_num = -1,
.data_in_num = 36
};
i2s_driver_install(I2S_NUM, &i2s_config, 0, NULL);
i2s_set_pin(I2S_NUM, &pin_config);