Drive Strength - mhightower83/Arduino-ESP8266-misc GitHub Wiki
Drive Current vs Drive Strength
Extracted from a post by ESP_Sprite answering "Can the output current of the esp32 GPIO be reduced?".
The 12mA is the maximum amount of current you can safely pull from the ESP32 [2]. A real chip actually can deliver much more: feel free to try it by making a pin high and using a multimeter in mA mode to measure the current to ground. (Not for too long, as I said, in theory it can damage the chip, although a few seconds probably won't harm.) You'll probably measure a current of 50mA'ish. Pull this current for too long, however, and you risk damaging the pad driver.
"Drive strength", when talking about VLSIs and digital logic, actually has a pretty narrow meaning: it relates to the fanout of a chip, which essentially is how many digital inputs you can drive from it [1]. The problem is that if you have a drive strength that is very low, the parasitic capacitance inherent in the input pins can take a while to charge. This leads to issues when you output e.g. a high-frequency clock signal: when you output a clock pulse (L->H->L), your clock signal has gone low again before the signal level on your output pin, slowed down because it has to charge the parasitic capacitance, has raised enough to indicate a high level. You want to raise the drive strength in this case: setting it to 80mA means that for the short while that the parasitic capacitance needs to charge, the pin can deliver 80mA. [3]
Now, why would we then make the drive strength adjustable instead of keeping it at max all the time? That has something to do with impedances. If the parasitic capacity is very low, or there's a parasitic inductance as well, driving a pin high as fast as possible can lead to overshoot and ringing and nasty EMI-related side effects. That is why you can set it per pin to whatever you need.
So concluding: the ESP32 can drive 50mA or so on an output pin, but this may lead to damage to the pin. Do not pull more than 12mA [2] from the pin in order to be sure that you're not killing the chip long-term. You can modify the drive strength of the pin in software if the output impedance gives you issues with AC signals, but do not assume this sets the DC current.
[1]: It's actually somewhat more complex than that, but as far as I know, fanout is the reason they came up with a number for this.
[2]: I see now that there has a very recent change in the datasheet that changes a value called 'Imax', or 'Maximum drive strength' from 12 to 80mA, seemingly replacing any value for DC current. I will look into getting this cleared up or corrected, but I highly doubt our analog team decided the ESP32 pins can drive a DC current of 80mA now.
[3]: For a slightly more experimental approach to understanding drive strengths, see https://.../Raspberry/Understanding_Outputs. It relates to the Raspberry Pi so the values are different and I'm not 100% sure if our pad drivers work in exactly the same way, but it may help to give you some intuition for this stuff.
From ESP8266 Hardware Design Guidelines, 1.4.3. Flash
ESP8266 Hardware Design Guidelines, 1.4.3. Flash reports using a 200Ω resistor in series with the SPI Flash Clock signal. The text says "..., which reduces the drive current and eliminates external interruption." I think their intended meaning was "lost in translation." It is easy to imagine that ringing on a clock signal could create read or write failures during a SPI bus transfer and they expressed this as an "external interruption". A high drive current with steep rise/fall times would lead to ringing and a series resistor would help resolve that. Without a series resistor, the board background noise would increase and when combined with the ringing would contribute to making a logic level undefined.
Ringing: more info and common text
"Pull up resistor (47k or 10k) on the MISO pin" This has proven to be a successful solution for many with the "ESP.deepSleep hangs after wakeup" issue. If this is from ringing caused by a strong Flash Chip output pin, a series resistor would be a better solution; however, a pullup is much easier to install on an existing board. TODO: Check DOUT for traces of ringing with an Oscilloscope. If ringing is present, this could explain a wide range of infrequent crashes like exception 28 and many others possibly due to bad ICACHE Flash reads. Note, Keep Tech-TX concerns on XTX Flash memory issues for sleep/wakeup. I think in the discussion for "ESP.deepSleep hangs after wakeup" issue, there are two causes being reported/discussed. Additional concerns for XTX and maybe other manufacturers, output drive current specifications are asymmetric, 1.6ma for low and 100ua for high. It is easy to see how a pullup might help. CMOS inputs are capacitive and I would expect a symmetric drive current.
Signal Limits
Espressif's ESP8266EX Datasheet 5.1. Electrical Characteristics is missing an "Absolute Maximum" specification all we have are operating values. On the low side for an input pin, we have -0.3V, and the high side at 3.6V. This is significant when you start to evaluate ringing at an input. I am seeing -1V with an output driven by GPIO5. It might be even lower since my oscilloscope is rated at 50MHz. As a reference point, SPI Flash datasheets commonly have -0.5V as the minimum allowed and an "Absolute Maximum" of -2V. This means anything in between would not damage the part, but may not provide reliable behavior. So with the ESP8266, we need to be above -0.3V. A series resistor can help with this. (TODO: get some pictures from the oscilloscope.)
0" wire
6" wire
12" wire
My Summary Thoughts
Reflecting on the above post these are my thoughts. Since the ESP32 is the next generation after the ESP8266, I'll assume they share some of their Characteristics. The ESP8266 GPIO pins also have a 12mA maximum output current rating; however, it does not have the ability to control Drive Strength. I am having trouble with Ringing with just about any length of wire. From that, I jump to the conclusion. The Drive Strength level on the ESP8266 must be equivalent to the ESP32 at maximum. External components will need to be added to control ringing. Transistors should always be driven through resistors. SPI Bus should be using series resistors, etc. To limit cross-talk the resistors should be placed as close to the ESP8266 module (output pins) as possible.
Tangent - Hyper Focused on Rise Time
Missing: My search attempts to find information on GPIO pin AC characteristics all failed. ex. rise and fall time, output capacitance, etc.
I have measured rise and fall time to be 3ns with a 50MHz oscilloscope. Unfortunately, 50 MHz is too slow to measure the rise/fall time accurately. A rise time of 3ns implies a bandwidth of 117 MHz. From other readings on Digital Oscilloscopes, it is better to estimate BW with BW = 0.45/RT. And to accurately measure that rise time, the oscilloscope needs a bandwidth 3 to 4 times that result.
Bandwidth is a topic all its own (searched on: "rise time to bandwidth"):
- ***** Understanding Oscilloscope Bandwidth, Rise Time and Signal Fidelity - "What is the Relationship Between Bandwidth and Rise Time?"
- Tektronix: How is bandwidth related to rise time for oscilloscopes?
- EDN: Bandwidth of a signal from its rise time: Rule of Thumb #1
- Thorlabs: Relationship Between Rise Time and Bandwidth for a Low-Pass System
- AllAboutCircuits: The Relationship Between Rise Time and Bandwidth in Digital Signals
- SignalIntegrityJournal: Back to Basics: Bandwidth and Rise Time - "... BW = 0.35/RT ... if you want a quick estimate of the highest frequency components in a signal, this is a good starting place."
While I can not accurately measure the rise time, I do know it is very fast and it can cause Ringing on the GPIO pins.
The fast rise times of the ESP8266 GPIO pins are causing Transmission-Line Effects when configured for output.
Some Reference material to study later:
- Transmission-Line Effects Influence High-Speed CMOS
- Fan-Out and Capacitance Loading Effects, (Rs calculation)
- Nice definition by an illustration of Rise time and Fall time etc.
- Clock Termination Techniques and Layout Considerations
- Design and Layout Guidelines for the CDCVF2505 Clock Driver, 3.4 AC Termination
- Clock Termination Techniques
- Theory