trying to read an ADC GPIO

mikemoy
Posts: 170
Joined: Fri Jan 12, 2018 9:10 pm

Re: trying to read an ADC GPIO

Postby mikemoy » Sun Jun 24, 2018 4:57 pm

Might this be of some help? Have a look here, in section 4.10, page 55.
https://www.espressif.com/sites/default ... ual_en.pdf

User avatar
mzimmers
Posts: 211
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: trying to read an ADC GPIO

Postby mzimmers » Mon Jun 25, 2018 2:05 pm

Hi Mike - yes, that's very helpful. I've passed it along to the HW people. Thanks.

User avatar
mzimmers
Posts: 211
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: trying to read an ADC GPIO

Postby mzimmers » Mon Jun 25, 2018 6:52 pm

So, it looks like we're going with GPIO21, which according to the table that Mike referenced, can be used as something called "VSPIHD," which if I'm reading the doc correctly, has something to do with accessing flash and SRAM access. Does this mean that if we try to use it for another purpose, we risk messing up the ability to access flash? And if so, should my code do something like read/save/reset the current settings for the pin before/after use?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: trying to read an ADC GPIO

Postby kolban » Mon Jun 25, 2018 9:46 pm

Think of a pin (pad) on the ESP32. Let us call in GPIO 21. That is a physically connectable piece of metal. Now look at Figure 7 in the TRM. GPIO 21 in that diagram is a "digital pad". Notice how it connects to a component called the "IO_MUX". This allows pads to serve a set of purposes. If you then look at table 19 you see the possible purposes served by a given pad based on the function property of IO_MUX. We find that GPIO 21 can be GPIO21, VSPIHD or EMAC_TX_EN ... through IO_MUX. That last part of the story is important. If this were ALL there was, then GPIO 21 could only be one of those 3 functions. However, look again at Figure 7. See also that the IO_MUX can be fed by something called the "GPIO matrix". To engage that, we can tell IO_MUX that for any given pad (eg. GPIO21) then the function of that pad will be determined by the "GPIO matrix". What that means is that ANY of the functions available for peripheral inputs/outputs can be associated (through GPIO matrix) with a given digital pad.

The key take away is that IO_MUX offers a finite and fixed set of mappings between pads and functions but, if desired, ALL the possible functions within an ESP32 can be associated with pad by telling IO_MUX to use the signals associated with GPIO matrix. By going down that route, you are going through extra internal code paths ... but stories seem to say that the overhead is not significant enough to practically care about.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

User avatar
mzimmers
Posts: 211
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: trying to read an ADC GPIO

Postby mzimmers » Mon Jun 25, 2018 10:02 pm

Hi Neil - thanks for the input. I was aware that a given GPIO pin could have multiple uses; my concern was whether it was my responsibility to coordinate the "sharing" of this pin with the rest of the system. In the example we're using (IO21), there's mention of VSPIHD. I wasn't sure whether the OS or some other underlying component might be using this pin, and if so, whether I need to prevent colliding with such use.

Sorry for the confusion; I hope I made a little more sense this time.

Thanks...

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: trying to read an ADC GPIO

Postby kolban » Tue Jun 26, 2018 12:34 am

Other than GPIO 6-11 which are used by flash, you should be safe to use other pins for interfacing purposes. Obviously, if your solution uses a pin for one purpose it shouldn't also use the same pin for a different purpose at the same time. You won't find interference in an out of the box ESP32 on GPIO21.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

User avatar
mzimmers
Posts: 211
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: trying to read an ADC GPIO

Postby mzimmers » Wed Jun 27, 2018 8:09 pm

Thanks, Neil. I'm getting some unexpected behavior on our board (the RTC isn't accepting updates from the NTP server) so I'm glad I can rule out pin collision. More likely we have some weird wiring issue on our prototype.

ESP_Dazz
Posts: 46
Joined: Fri Jun 02, 2017 6:50 am

Re: trying to read an ADC GPIO

Postby ESP_Dazz » Wed Jul 04, 2018 2:06 pm

I was just hoping that there would be a location where all the pertinent information for GPIOs (including any use by the ESP32 module itself, for example GPIO32 which evidently is the input to the RTC).

For more information about ESP32 pin usage, please refer to the following table located in the appendix section of the ESP32 datasheet.
GPIO Table.JPG
GPIO Table.JPG (234.46 KiB) Viewed 330 times

Who is online

Users browsing this forum: Google [Bot] and 19 guests