Wired ADC Signal when using I2S DMA
Posted: Tue Mar 09, 2021 8:31 am
Hi guys,
I was trying to use ADC for super fast sampling with I2S and DMA. The I2S config is as below:
I use a PWM to test ADC. However, when the frequency of signal exceeds 1kHz, some wired peaks appears at each rising. Take a 10kHz signal for example:
The result from oscilloscope shows there is no peak actually, so something must be wrong with ADC or I2S. Is there anyone who meets the same problem?
I was trying to use ADC for super fast sampling with I2S and DMA. The I2S config is as below:
Code: Select all
void i2sInit()
{
i2s_config_t i2s_config = {
.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX | I2S_MODE_ADC_BUILT_IN),
.sample_rate = 400000,
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
.channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
.communication_format = I2S_COMM_FORMAT_I2S_MSB,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
.dma_buf_count = 4,
.dma_buf_len = 16, // small dma buffer to ensure the i2s sampling rate is equal to real ADC sampling rate
.use_apll = false,
.tx_desc_auto_clear = false,
.fixed_mclk = 0
};
adc1_config_channel_atten(ADC1_CHANNEL_0,ADC_ATTEN_DB_11);
adc1_config_width (ADC_WIDTH_12Bit);
i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);
i2s_set_adc_mode(ADC_UNIT_1, ADC_INPUT);
}
...
// then using i2s_read() to read from dma buffer
...