esp-idf: [TW#16751] ADC1 does not work in Multiple-channel scanning by pattern table, when enable WiFi.

As stated in the “ESP32 Technical Reference Manual”, in the “27.3.5 DIG SAR ADC Controllers” can perform high-speed scanning by pattern table. This is true only for the ADC2, because similar functionality is already exists in bootloader_random_enable(), selected analog inputs in the template table can read the analog signal in DMA. But this is not what we need, when you turn on the WiFi, the scaning is broken because wifi driver use some ADC2 lines.

  • ADC1 does not work in single scanning mode by pattern table?
  • Unfortunately this example: i2s_adc_dac does not work, gets audio to ADC1 and writing empty data, even the channel number in the DMA data structure does not appear.

edited: 11.12.2017

I success to start the ADC1 I2S/DMA scan in the master branch of esp-idf, but if several conditions are fulfilled:

  • firstly, you need to change the power mode on the ADC_FORCE_ENABLE in the function adc_power_on(). I suggest for the function adc_power_on() the power mode to pass as argument so that when it is called from i2s_param_config (), the controller should be powered on permanently.

  • secondly, turn off the I2S controller reset in the function i2s_stop()

// I2S [i2s_num] -> conf.tx_reset = 1;
// I2S [i2s_num] -> conf.tx_reset = 0;
// I2S [i2s_num] -> conf.rx_reset = 1;
// I2S [i2s_num] -> conf.rx_reset = 0;

but since this affects the solution of the “bugfix/i2s_bck_polariy” I just deleted the function i2s_stop() here:

--- i2s.orig.c  2017-12-11 15:32:56.000000000 +0200
+++ i2s.c       2017-12-11 15:33:24.526230939 +0200
@@ -1043,7 +1043,6 @@
             ESP_LOGE(I2S_TAG, "Register I2S Interrupt error");
             return err;
         }
-        i2s_stop(i2s_num);
         err = i2s_param_config(i2s_num, i2s_config);
         if (err != ESP_OK) {
             i2s_driver_uninstall(i2s_num);

because i2s_stop() is called later from the function i2s_set_clk(). Apparently the repeated discharge here is superfluous and hinders the work.

BUT THAT IS VERY IMPORTANT !!! when WIFI is turned on when the esp_wifi_set_mode() function is started, the previously running scan of ADC1/I2S/DMA is stopped, data in DMA does not change anymore, although I2S interrupts still arrive.
I think that the WiFi driver knocks down the settings of the DIG SAR ADC1 controller, but this is beyond my visibility, so I ask the guys from the Espressif to help solve this problem!

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (13 by maintainers)

Commits related to this issue

Most upvoted comments

It seems that ADC1 is working in scanning mode, if you return back to the feature(I2S-ADC): add ADC mode for I2S but after the Merge branch ‘feature/i2s_built_in_adc’ into ‘master’ it ceased.

@costaud Please make feedback to my comment. We really have such issues, can you tell how to get around them? I also failed to start ADC->I2S together with the enabled WiFi.