ADC1 can not sampling in I2S scanning mode when enable WiFi.

phonec
Posts: 3
Joined: Thu Nov 23, 2017 7:53 am

ADC1 can not sampling in I2S scanning mode when enable WiFi.

Postby phonec » Tue Dec 12, 2017 3:29 pm

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. Unfortunately this example:i2s_adc_dac does not work in master branch, gets audio to ADC1 but I2S writing empty data in DMA.
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(), you can remove it:

    Code: Select all

    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:

    Code: Select all

    --- 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 called, 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.

We ask the guys from the Espressif please help solve this bug!

ESP_Sprite
Posts: 8999
Joined: Thu Nov 26, 2015 4:08 am

Re: ADC1 can not sampling in I2S scanning mode when enable WiFi.

Postby ESP_Sprite » Thu Dec 14, 2017 9:14 am

Thanks for your bug report! We're aware of the fact that the sample is broken; we have a fix in the pipeline. I don't know if we know about the WiFi thing yet. Could you please make a Github issue about this ( https://github.com/espressif/esp-idf/issues/new ) so we can track this issue better?

phonec
Posts: 3
Joined: Thu Nov 23, 2017 7:53 am

Re: ADC1 can not sampling in I2S scanning mode when enable WiFi.

Postby phonec » Thu Dec 14, 2017 11:47 am

Thank you for your answer, I already opened this issue TW#16751.
This would be a good feature for ESP-IDF in release 3. We are already scanning 2x ADC1 channels at a speed of 204800 samples per second for each, but without the inclusion of Wifi :)
I am ready to help than I can to solve it faster.

Who is online

Users browsing this forum: No registered users and 89 guests