I'm trying to acquire a single channel analogue input using the I2S DMA. This is somewhat successful in that I can configure the I2S and read data correctly and it gives me sensible values. However. I seem to be getting two channels of the same measurement, separated by 1/f, instead of one. The full test code can be viewed here.
The config being used is shown below:
Code: Select all
i2s_config_t i2s_config ; i2s_config.mode = i2s_mode_t(I2S_MODE_MASTER | I2S_MODE_RX | I2S_MODE_ADC_BUILT_IN); i2s_config.sample_rate = SAMPLE_RATE; // 120 KHz i2s_config.dma_buf_len = NUM_SAMPLES; // 512 i2s_config.channel_format = I2S_CHANNEL_FMT_ONLY_RIGHT; // Should be mono but doesn't seem to be i2s_config.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT; i2s_config.use_apll = false, i2s_config.communication_format = I2S_COMM_FORMAT_I2S; i2s_config.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1; i2s_config.dma_buf_count = 2; //install and start i2s driver i2s_driver_install(I2S_NUM_0, &i2s_config, 1, &i2s_event_queue); // Connect ADC to I2S i2s_set_adc_mode(ADC_UNIT_1, ADC1_CHANNEL_6); //i2s_set_clk(I2S_NUM_0,SAMPLE_RATE,I2S_BITS_PER_SAMPLE_16BIT,I2S_CHANNEL_MONO); // This doesn't work either
The bottom two are the result of the same data but de-interleaved. The raw measurements (buffer dump of the i2s_read_bytes) can be found here. For these two plots, I am assuming that we have two channels, each sampling at f/2 which yield the expected results.
So it seems I have two interleaved channels, of the same signal, at f/2 sample rate. How do I sample a single channel channel @ 120kHZ instead of 2 channels at 60 kHz?