Confused over i2s_config_t
Posted: Sun Jun 30, 2019 12:37 pm
So, I have a big block of data that I want to write to I2S. The data consists of 8-bit mono audio, sample rate 8kHz. I want the output on the DAC (pin 25).
I figured that a way to do it is to write in blocks of 512 bytes using i2s_write(). However I am getting
when calling:
So it looks like I have configured the driver wrong. Here's how I set i up:
I'm confused as to how to set .dma_buf_count and .dma_buf_len. Presumably there's a relationship between sample_rate, bits_per_sample, dma_buf_count and dma_buf_len, but I am at loss as to know how to set it.
I'm assuming that dma_buf_count is a more-or-less arbitrary number, and that the dma_buf_len multiplied by dma_buf_count must equal some other number.
I figured that a way to do it is to write in blocks of 512 bytes using i2s_write(). However I am getting
Code: Select all
E (283) I2S: Invalid bits per sample
Code: Select all
ret = i2s_driver_install(0, &i2s_config, 0, NULL);
Code: Select all
static const i2s_config_t i2s_config = {
.mode = I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_DAC_BUILT_IN,
//.mode = I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_DAC_BUILT_IN,
.sample_rate = 8000,
.bits_per_sample = 8,
.channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
.communication_format = I2S_COMM_FORMAT_I2S_MSB,
.intr_alloc_flags = 0, // default interrupt priority
.dma_buf_count = 4,
.dma_buf_len = 512/4/8,
.use_apll = false
//.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1
};
I'm assuming that dma_buf_count is a more-or-less arbitrary number, and that the dma_buf_len multiplied by dma_buf_count must equal some other number.