# GPIO state of MCU (AVR) with no supply voltage

In general: what state do the GPIOs of a MCU (an AVR in my case) have when there is no supply voltage and the MCU is "off". Am I right that the pins are floating as there isn't any "reference" for the logic level at all.

In special: I have a bilateral switch (BS) shifting a variable voltage (provided by a DAC) for an analog device (AD). Both the BS and the DAC are controlled by a MCU. As the BS's output will be floating when its input is not set high by the MCU, I need a pulldown at the output to define the low-state. I've attached a simplified circuitry illustrating the scenario.

If the MCU is running, everything is clear: the BS will supply the AD with an analog signal as long as gpio1 is high.

But if (for a reason) the 3.3V power supply is not there, I still need to have a defined voltage at the AD's Ain pin. So if my supposition, that the gpios of an inactive MCU are floating, is correct, the following circuitry should meet my requirements:

• MCU active: gpio2 is configured as low output -> strong pulldown (1k & 10k in parallel equals 0k9) outweighs 100k which leads to a negligible voltage divider. Ain is pulled to low voltage (not ground exactly, but close to it - 0.2V)

• MCU inactive: gpio2 is floating -> weaker pulldown (10k) and not negligible voltage divider (100:10) leading to a defined voltage of 0.9*24V = 2.2V.

I'm quite sure that the circuitry as such makes sense, but if it works or not completely depends on the behaviour of gpios when there is no supply voltage for the MCU. Can this damage the MCU? (I guess not, as long as R1 is high enough)

• Your first circuit looks just fine to me. I didn't get why do you need any pull-up, it will create additional difficulties/unpredictables as described in my answer. Unless you require the Ain pin to have "defined voltage of 2.2V" at all times. – Ale..chenski Sep 5 '18 at 21:26
• You mean the pullup in the second circuit? I need it, because I need a voltage higher that 1.5V at Ain of AD when the MCU is not available. If it IS availabke I want it to control the AD. The minimum input to AD is 0.3 V, so I have some space left below this threshold – Sim Son Sep 6 '18 at 10:01

The simplest way to imagine the MCU pins with no power is like this:

Basically I would say that the input is floating, but if you apply any voltage to that pin, then it will flow through the upper protection diode and begin parasitically powering the circuit.

What's going to happen in your circuit, is that once the voltage increases past the diode threshold (0.6v), current is going to start flowing through that 1k, and the voltage isn't going to get much higher than that. Without doing the math, i'd say like.. 0.8v

I'm not sure what exactly the purpose of the gpio2 pulldown is, but you could hook it up like this instead:

simulate this circuit – Schematic created using CircuitLab

• The default pulldown (in no-MCU-operation) is 10k and by the 1k pulldown at gpio2 I'm able to "remove" the default one for variable operation (control of AD in voltages between 0.3 and 2.5 V) – Sim Son Sep 6 '18 at 10:07

No, the inputs are not floating, and yes, applying a voltage to them when power is off can lead to damage. This is true for just about any modern IC, where the data sheet does not explicitly say otherwise.

In the case of say an ATmega328p, we can see it in the "Absolute Maximum Ratings" section

Voltage on any Pin except RESET with respect to Ground . -0.5V to VCC+0.5V

These limits are typically due to the presence of ESD protection diodes which divert currents on the I/O pins to the supply rails. When the supply rail is at ground potentially, the allowed input range is just less than a diode drop higher or lower. Applying a higher voltage (at least without large series resistance) would cause the protection diode to conduct, and could easily provide enough current to damage it. Additionally, it would attempt to raise the entire board's supply net. Even if this did not cause damage it can lead to putting various circuitry into a state from which power on reset would not cleanly work (for example, while it's not a problem the AVR seems to have, I've seen other systems which would not boot if a USB-TTL adapter's data lines were connected before the system was powered, even if that adapter was connected via substantial series resistance)

If you need a defined level, that level should be ground via a pulldown resistor. Even better, also powerdown whatever the MCU is connected to.

Remember also that even if the pin is not floating when power is off, it will be floating between reset and when it is configured as an output. Especially if something like a serial bootloader is involved, that could potentially be a substantial period of time.

• "Applying a higher voltage (at least without large series resistance) would cause the protection diode to conduct, and could easily provide enough current to damage it." - wrong. The ESD diode will conduct and charge the Vcc rail up, that's it. Unless the Vcc is heavily crow-barred by external means. – Ale..chenski Sep 5 '18 at 4:02
• Unless the driving source is current limited, the protection diode will end up carrying the entire operating power consumption of the board it attempts to power into operation. Can you sometimes get away with it briefly, especially in circuits which provide little operating load? Yes, I've had it happen accidentally. But you only get away with operation outside the Absolute Maximum Ratings until you do not. – Chris Stratton Sep 5 '18 at 4:15
• In addition to what Chris said, the maximum allowable continuous current is rarely specified for the ESD diodes (that's not what they're designed for!) so the most prudent course of action is to avoid designing for any appreciable continuous current. – ajb Sep 5 '18 at 4:47
• @ajb and Chris, nowadays every IC ever made has to pass JESD78 latch-up test, which is at least 100 mA injection into unpowered IC. Wihout being destructed. Anyone who worked in semiconductor industry knows this. You must work really hard to get this kind of currents in real boards. So please spare your comments, please. – Ale..chenski Sep 5 '18 at 21:00
• @Ale..chenski - no. Those tests are 2-10 millisecond duration events. Not continuous. One should not design a board to put substantial currents through the protection diodes under ordinarily expected conditions. – Chris Stratton Sep 5 '18 at 21:05

One typical problem with unpowered MCU while its GPIO have some path to a voltage rail (like 2.2V from 100k : 10 k divider via R3) is that the MCU power rail will "leak-up" via ESD protection diodes (typically built in GPIO pads). The Vcc voltage rail will be charged up to the input voltage minus 0.5 bandgap diode voltage, minus some leakage via other resistors, hard to predict. Since Vcc will charge up, the "absolute maximum ratings" will unlikely to be exceeded.

Some part of problem is that usual LDO regulators don't have anything to keep their output at zero when Vin is not there. To keep the LDO output down, there are special models with "output discharge", or you need to add explicit bleeding resistors on Vcc rails.

I didn't analyze the exact path in your design, but I hope this answer will give you an idea where to look.

ADDENDUM1: There is a classical example when an un-powered CMOS IC (like CD4017 counter) would even function and count states if just a clock is applied, say a 5-V clock. The Vdd rail will charg up to 4 - 4.3 V level via upper ESD diode, and the counter will happily toggle.

ADDENDUM2: Similar effects frequently occur if an unpowered MCU is connected to a powered interface (say, I2C pull-ups, or USB). The MCU rails might be charged up partially, to some intermediate (1 - 2 V) level. When powered back, the ICs internal circuitry might fail to receive valid internal reset and fail to function properly. This is the major reason why self-powered USB devices are prohibited from any active "back driving" when the host is in unpowered state.

• Having VCC "charge up" does not mean that the Absolute Maximum Ratings are unviolated, in fact, it only charges up because they are violated. Forward biasing of the protection diodes is a violation of the ratings of I/Os of the conventional type - it is specifically the condition which the ratings prohibit. That doesn't mean slight instances will immediately kill the ic, but it is a violation of specifications. And if there is anything drawing power on an ongoing basis, they stay violated. – Chris Stratton Sep 5 '18 at 21:06
• @ChrisStratton, I am not sure what you are objecting to. I am just warning about a real-life situation when one part of system is power-gated while another is not, regardless of whether any ratings are violated or not. If OP would ask anything about violating any ratings, you are welcome to answer it with your brilliance. Slight violation of some nearly arbitrary imposed rule doesn't mean the IC gets damaged, maybe in 5000 years, but a leakage via even 1k can cause fundamental functional problems. That was my point, which you failed to see in your answer. – Ale..chenski Sep 5 '18 at 21:51
• Actually if had read with a little care you would have noted that I raised the issue of malfunction and gave an example, before you did. So no, I didn't overlook anything. What I did was point was the error in your claim that the maximum ratings would not be exceeded; in fact they are. – Chris Stratton Sep 5 '18 at 23:17
• @ChrisStratton, okay, you did mention the raise of the entire board's supply net. I stand corrected. However, if we continue our senseless barbs, your statement that "Applying a higher voltage ... would cause the protection diode to conduct, and could easily provide enough current to damage it.". The conducting diode will raise the rail just enough to compensate for current at the level of forward voltage, so it is not "easy to provide enough current to damage it". It is true however that maximum ratings are set below the typical forward voltage of a body diode, to avoid liabilities. – Ale..chenski Sep 6 '18 at 1:30
• @ChrisStratton On some ICs there is an allowed current through the protection diodes and this specification should hold even when not powered. Usually not much more than what is required for resistor protected static discharges but I have seen circuits that are powered deliberately and accidentally through the protection diodes. The most common unintended example is to see a toy display light up when forcing the wheels around. – KalleMP Sep 6 '18 at 8:54