-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DMA ADC Fails On Connection to AP when in STA (station) mode (IDFGH-239) (IDFGH-1442) #3714
Comments
I would like to know as well. Spent well over a week trying to get ADC1 working before finding these threads. |
What did you do to get the pattern table working? I got it to work by removing the static in front of the 2 functions in the file in the esp-idf/components/driver/rtc_module.c and added the declaration into esp-idf/components/driver/include/driver/adc.h esp_err_t adc_set_i2s_data_len(adc_unit_t adc_unit, int patt_len); I then call these functions in my code. I then got the data interleaved. You have to double the sample rate for 2 channels. I think there is some way to copy the driver files into your components directory and not modify the |
Re. pattern table usage, you might be interested in the example code I posted from issue #3263 . @mishafarms did you get a problem with weird channel ordering (like 5, 5, 6, 6, 5, 6, 6)? Re. ADC issues, I notice you're using the APLL, and you might be running into the issue I found here (APLL cannot be used while using the I2S direct-from-ADC mode): #3692 . Re. the ADC issue itself, I dimly remember that one of the ADC modules is incompatible with the wifi module being enabled, but I'll have to dig that up. |
Oh, it was ADC2 and you're using ADC1, so it's probably not that. From here:
|
I tried disabling APLL, no change. I did not see any weird channel ordering. Michael |
@michafarms I suspect you might not really be using the APLL in your posted code anyway. The
|
@mishafarms It seems like we're working with similar features. I'm totally unable to get the channel ordering/pattern table working though. If you have a few minutes, do you think you could build and run the project here and see if you get the same bug I do? It would be a huge help just to have another data point for this. |
ADC1 pattern table! => SOLVED I finally got the ADC1 pattern tables to work, but not with WiFi connected. Sample rate can be from 5kHz up to 1.3MHz! I also tried starting WiFi after i2s_adc_enable(); but before i2s_read(); . It doesn't help. Sample output from channel 0, 3, 6, 7, looks like this: The full code...
and replace everything in app_main.c with this: |
That is great. I wish someone would look at the original issue. Michael |
All, I want to jump in here, I have exactly the same. All is running, then as soon as STA connects it stops, keeping the existing value in all entries... |
Running @giPeteR example connected to STA I am getting changing ADC raw values. This is on fairly recent master branch. |
Hi, thanks!! |
Guys this is not the same, and I am not running on Arduino. I have tried to initialise the ADC after WIFI and before WIFI and I get the same results. |
I also am NOT using the Arduino. I am using a single channel. I am on the master branch of esp-idf. I think that this is still an issue. |
@mishafarms can you reproduce with the example given by giPeteR above? What settings necessary to reproduce? |
@negativekelvin I just ran giPeteR's code and it works. I get all the channels data. If you put this code in the app_main function.
You get the correct data for about 5 samples and then I (10996) ADC/DAC: 79 07 7e 07 ce 60 98 30 7d 07 7f 70 c0 60 cb 30 I (12006) ADC/DAC: 7f 07 30 70 80 61 e3 33 7e 07 31 70 80 61 e3 33 I (13006) ADC/DAC: 80 07 4f 70 8f 61 f2 33 7f 07 4f 70 8f 61 f0 33 I (14006) ADC/DAC: 7e 07 62 70 93 61 fa 33 7f 07 62 70 96 61 fa 33 I (15006) ADC/DAC: 7d 07 31 70 71 61 e1 33 80 07 32 70 70 61 e0 33 I (16006) ADC/DAC: e7 33 e7 33 e7 33 e7 33 e7 33 e7 33 e7 33 e7 33 I (16506) tcpip_adapter: sta ip: 192.168.252.140, mask: 255.255.255.192, gw: 192.168.252.129 I (18006) ADC/DAC: e7 33 e7 33 e7 33 e7 33 e7 33 e7 33 e7 33 e7 33 You can see at first we get all the channels and then once Wifi is re-established, we stop reading |
@mishafarms thanks, I am able to reproduce. However adding one thing seems to resolve it: |
@negativekelvin You have found a workaround. Thank you. I think I can live without Michael |
When using WIFI, if the power saving mode is not used, the SAR power domain will be turned off when entering the power saving mode to reduce power consumption. This is the root cause of this problem. The current solution is to set WIFI to WIFI_PS_NONE mode. |
I think you mean
So will there be a way for the user app to take a lock to prevent this while still using powersave? |
Yes, we will implement this. |
@negativekelvin |
Thank you guys, we will implement this workaround asap! |
THANKS! Now everything works. (I wonder what happens at a reconnect? Will it remember WIFI_PS_NONE?) |
@negativekelvin I also encountered this problem, using your solution ESP-IDF Version: v4.1-dev-815-ga45e998-dirty The full code |
@mishafarms #3973 has been fixed, would you please help try the fix mentioned in there? Thanks. |
Hi @mishafarms, we think the issue is fixed now and therefore we are closing it to keep our backlog manageable. If you don't agree with this decision, please let me know. Thank you, Tomas |
December 2023 this issue persists on the Esp32s3 ESP_IDF v5.1.1 esp_wifi_set_ps(WIFI_PS_NONE) is irrelevant Order of ADC Init and WIFI Init are also irrelevant, anytime the esp_wifi_start() is called, and the ADC1 continuous is running, the DMA buffer stops being updated. I can provide code and logs as requested |
I second that this issue is still present, or was regressed back into v4.4.8. Once WiFi is started and a scan initialized, interrupts no longer work on GPIO 36 or GPIO39. Reading the value of the pin itself with a scope or in software with gpio_get_level every 10ns is high on the LyraT v4.3 board. Something is definitely wrong with WiFi and these two pins, that is not just the 80ns burst low as specified in the errata. |
This is a duplicate of #1977. It appears that has been open for over a year.
Development Kit: Platform IO
Kit version (for WroverKit/PicoKit/DevKitC): v3.1-dev-661-gf586f5e6
Core (if using chip or module): ESP32 Lolin
IDF version v3.1-dev-661-gf586f5e6
Development Env: VS Code + PlatformIO
Operating System: Windows
Power Supply: USB
Platform Espressif 32 (Stage)
Updating espressif32 @ 29b3a81
Updating tool-esptoolpy @ 1.20100.0
Updating framework-arduinoespressif32 @ 6826508
Updating tool-espotapy @ 1.1.0
Problem Description
When acquiring ADC data through DMA transfers and the device is in station mode (WIFI_MODE_STA). As the device connects to the AP, the ADC DMA buffer ceases to show valid data and continues to read (a probably random) fixed value.
This does not happen in WIFI_MODE_AP or WIFI_MODE_APSTA
Expected Behavior
The ADC should continue to read valid data.
Actual Behavior
Steps to repropduce
Code to reproduce this issue
#include <Arduino.h>
#include "freertos/FreeRTOS.h"
#include "freertos/event_groups.h"
#include "esp_log.h"
#include "driver/i2s.h"
#include "soc/syscon_reg.h"
#include "driver/adc.h"
#include "esp_wifi.h"
#include "esp_event_loop.h"
#include "WiFi.h"
#include "dac_cosine.h"
#define TAG "adc_i2s"
// Physically connect pins 25 and 34
uint32_t SAMPLE_RATE = 120E3;
uint32_t NUM_SAMPLES = 64;
uint32_t SIGNAL_FREQ = 10E3;
#define WIFICLIENT_SSID ("MYAP")
#define WIFICLIENT_PWD ("1234567")
#define WIFISERVER_SSID ("MYDAQ")
#define WIFISERVER_PWD ("1234567")
IPAddress local_IP(192,168,4,22);
IPAddress gateway(192,168,4,22);
IPAddress subnet(255,255,255,0);
static QueueHandle_t i2s_event_queue;
static EventGroupHandle_t wifi_event_group;
void WiFiEvent(WiFiEvent_t event)
{
switch(event) {
case SYSTEM_EVENT_STA_GOT_IP:{
Serial.println();
Serial.println("CONNECTED");
Serial.println();
break;
}
default:{
break;
}
} // switch
} // WiFiEvent
void setup(){
Serial.begin(921600);
WiFi.onEvent(WiFiEvent);
WiFi.mode(WIFI_MODE_STA);
WiFi.begin(WIFICLIENT_SSID, WIFICLIENT_PWD);
}
void loop(){
uint16_t i2s_read_buff[NUM_SAMPLES];
system_event_t evt;
if (xQueueReceive(i2s_event_queue, &evt, portMAX_DELAY) == pdPASS) {
if (evt.event_id==2) {
i2s_read_bytes(I2S_NUM_0, (char*)i2s_read_buff, NUM_SAMPLES * 2, portMAX_DELAY);
for (int i=0;i<NUM_SAMPLES;i++){
Serial.printf("%X, ", i2s_read_buff[i] & 0xFFF);
}
Serial.println();
}
}
}
The text was updated successfully, but these errors were encountered: