GPIO32/33 input level affects on ADC1 values

spider
Posts: 2
Joined: Sat Dec 19, 2020 4:12 am

GPIO32/33 input level affects on ADC1 values

Postby spider » Wed Feb 08, 2023 6:38 am

Look like External input signal to GPIO32 or GPIO33 have internal effect to ADC1_CHANNEL_0 or ADC1_CHANNEL_3 (IO36 or IO39).
I have wrote sample code to reproduce effect:

Code: Select all

void setup() {
  // initialize serial communication at 115200 bits per second:
  Serial.begin(115200);
  
  //set the resolution to 12 bits (0-4096)
  analogReadResolution(12);

  pinMode(32, INPUT | OUTPUT | OPEN_DRAIN| PULLUP);
  pinMode(33, INPUT | OUTPUT | OPEN_DRAIN| PULLUP);
}

void loop() {
  static uint8_t state = 1;

  Serial.printf("Switch GPIO32 GPIO33 to %s\n", (state)?"HIGH":"LOW");
  
  digitalWrite(32, state);
  digitalWrite(33, state);

  for (uint8_t n=0; n<15; ++n) {
    // read the analog / millivolts value for pin 2:
    int analogValue = analogRead(36);
    int analogVolts = analogReadMilliVolts(36);
    
    // print out the values you read:
    Serial.printf("ADC analog value = %d, ",analogValue);
    Serial.printf("ADC millivolts value = %d\n",analogVolts);
    
    delay(100);  // delay in between reads for clear read from serial
  }

  state ^= 1;
}
as result we can see next:
Switch GPIO32 GPIO33 to HIGH
ADC analog value = 2224, ADC millivolts value = 3165
ADC analog value = 3787, ADC millivolts value = 3165
ADC analog value = 3825, ADC millivolts value = 3165
ADC analog value = 3886, ADC millivolts value = 3165
ADC analog value = 3925, ADC millivolts value = 3165
ADC analog value = 3985, ADC millivolts value = 3165
ADC analog value = 4023, ADC millivolts value = 3165
ADC analog value = 4051, ADC millivolts value = 3165
ADC analog value = 4095, ADC millivolts value = 3165
ADC analog value = 4095, ADC millivolts value = 3165
ADC analog value = 4095, ADC millivolts value = 3165
ADC analog value = 4095, ADC millivolts value = 3165
ADC analog value = 4095, ADC millivolts value = 3165
ADC analog value = 4095, ADC millivolts value = 3165
ADC analog value = 4095, ADC millivolts value = 3165
Switch GPIO32 GPIO33 to LOW
ADC analog value = 1589, ADC millivolts value = 1208
ADC analog value = 283, ADC millivolts value = 378
ADC analog value = 240, ADC millivolts value = 343
ADC analog value = 208, ADC millivolts value = 313
ADC analog value = 176, ADC millivolts value = 289
ADC analog value = 145, ADC millivolts value = 265
ADC analog value = 119, ADC millivolts value = 244
ADC analog value = 97, ADC millivolts value = 225
ADC analog value = 77, ADC millivolts value = 207
ADC analog value = 59, ADC millivolts value = 191
ADC analog value = 42, ADC millivolts value = 178
ADC analog value = 25, ADC millivolts value = 160
ADC analog value = 14, ADC millivolts value = 153
ADC analog value = 0, ADC millivolts value = 142
ADC analog value = 0, ADC millivolts value = 142
External connections:
GPIO32 pulled up via 1k to 3,3V
GPIO36 connected via resistive divider (47k|91k) between VCC and GND.

Same situation with ESP-IDF framework. Not only on Arduino.

How one GPIO can take effect to other GPIO?!

andreyVylix
Posts: 2
Joined: Tue Oct 18, 2022 5:25 pm

Re: GPIO32/33 input level affects on ADC1 values

Postby andreyVylix » Tue Jan 30, 2024 10:10 am

I also noticed this problem, but not only for these two channels, but in principle for all ADC 1 channels. Perhaps this is a problem with the wiring of the wroom module. In any case, the useful signal is duplicated to other channels only when they are not connected to external signal sources. When external sources are connected, the channels receive only a constant component.
Attachments
adc3.png
adc3.png (178.7 KiB) Viewed 3485 times
adc(3+0).png
adc(3+0).png (180.71 KiB) Viewed 3485 times

Who is online

Users browsing this forum: No registered users and 33 guests