31

I've heard that leaving a pin floating on an MCU when configured as an input (vs. the default output) is bad for the pin, and can eventually cause it to fail prematurely. Is this true? N.B. in my instance the pin is floating somewhere between 0.3V and 1.3V due to an incoming video signal. This sometimes falls in the no man's zone of 0.8V - 2.0V when operating from 3.3V.

Thomas O
  • 31,546
  • 57
  • 182
  • 320
  • 1
    Have you checked the datasheet and MCU family documentation? They should have some pretty definite answers and you can see how the pins are implemented internally. – XTL Nov 28 '10 at 10:50
  • @XTL, I scanned through them, but didn't find any references to it. They do say that floating pins can enter undefined states but don't mention whether it could cause problems. – Thomas O Nov 28 '10 at 10:52
  • There's a difference between a floating digital input and an input defined as analogue. Sounds like this is an analogue input. – Martin Nov 29 '10 at 13:13
  • @Martin I'm unable to make the pin an analog input. I have a ~125ns time slice for each pixel on the video (25ns instruction clock), so can't expend a single nanosecond more. – Thomas O Nov 29 '10 at 13:16
  • 2
    What MCU are you using that defaults all pins to **output**? That sounds like a recipe for disaster. – Connor Wolf Aug 01 '11 at 22:34

6 Answers6

33

Problem:
Leaving a pin configured as an input floating is dangerous simply because you cannot be sure of the state of the pin. Like you mentioned, because of your circuit, your pin was sometimes LOW or sometimes in no-man's land or could sometimes go to HIGH.

Result:
Essentially, the floating input WILL definitely cause erratic chip operation or unpredictable behaviour. I have noticed some chips froze by simply moving my hand closer to the board (I wasn't wearing a ESD wrist band) or some would have different startup behaviour each time the board would powerup.

Why:
This happens simply because if there is external noise on that pin, the pin would oscillate, which would drain power as CMOS logic gates drain power when they switch states.

Solution:
Most micros nowdays have internal pullups as well, so that could prevent this behaviour from occuring. Another option would be to configure the pin as an output so it does not affect the internals.

IntelliChick
  • 1,237
  • 2
  • 13
  • 18
  • 3
    If you're using it as an input it will definitely cause erratic inputs, but does it really affect other parts of the chip and cause startup issues? – endolith Nov 27 '10 at 03:12
  • 3
    If I'm ignoring the pin and not using it for any peripherals would it still cause problems? – Thomas O Nov 27 '10 at 10:04
  • @endolith and Thomas - I think mikeselectricstuff has answered this for you! It could cause problems simply by introducing noise into other parts of the system. I know it was because of the floating pin, because as soon as I configured it to an output, the problems went away! – IntelliChick Nov 28 '10 at 22:31
  • 2
    I don't understand how a floating piece of metal can introduce noise to other parts of the system. It picks up noise, certainly, but if you're not paying attention to the input, that shouldn't matter. Are the problems with waving hands nearby really related to *unused* floating inputs? – endolith Nov 30 '10 at 15:22
  • TIL floating pins aren't harmless. Thanks IntelliChick and @Yann! – Nick Johnson Aug 02 '11 at 01:31
  • @endolith You are mostly correct, a floating pin often oscillates states and causes power draw. This on its own should not cause a problem, I have never seen any such issue. However, I would bet money a poorly decoupled power supply might allow that noise to cause real issues. The one thing I have to say is that I disagree very heavily with this answer that it will always cause a problem. – Kortuk Nov 17 '12 at 07:13
  • @Kortuk: How does an input oscillate? How does this cause problems in other circuits? – endolith Nov 18 '12 at 17:38
  • @endolith A floating him impedance input will often dance all over the place. It does not really matter what the pin is doing, that tiny oscillation gets the input circuit for the pin to bounce around with it as it changes states. As it changes state it draws power, this causes a power draw that will sync up with the input, especially if the input is bouncing from coupled noise nearby, and easily make any power conditioning problem worse. Again though, I have never ever seen this cause anything more then power draw, but I can imagine the affect on a poorly decoupled circuit. – Kortuk Nov 19 '12 at 01:50
  • But how does a resistor fight the "floating pin"? – Pithikos Jan 14 '15 at 09:37
14

It's a little worse than just being in an unknown state, or toggling needlessly. Digital circuits nowadays are mostly of CMOS type, with transistors switching both high and low sides; when we have clear 1s and 0s, they are either off or saturated, the two most efficient states for the transistors to be in. In between, however, is a region of linear operation; it's used for analog amplifiers, but it is not as efficient as the extremes - meaning more power is wasted as heat in the transistor. In the worst case, both the high and low side transistors leak thus (because the pin is in fact neither high nor low), and they can then combine to cause a notable current within the chip as they try to drive the internal state both high and low - possibly doing the same to the next gate in a chain reaction. The heat could become a problem even if the power isn't. IntelliChick's solutions still apply.

For pins also connected to ADCs, some microcontrollers offer the function to disable the digital input buffer, to prevent both this problem and leakage distorting the signal.

Yann Vernier
  • 2,814
  • 17
  • 15
6

In practice the main effect is increased power consumption. If a pin is actually floating as opposed to connected to some indeterminate voltage source, it is possible for oscillation to occur, which as well as increasing power draw may introduce noise into other parts of the system. Any pin which has the ability to be used for an ADC or comparator input will have the facility to disconnect the digital input buffer to avoid this problem. (DIDR on AVR, ADCON1/ANSEL on PIC)

mikeselectricstuff
  • 10,655
  • 33
  • 34
  • What exactly would oscillate, and why? – endolith Nov 30 '10 at 15:22
  • @endolith - The input buffer on the pin. Think about a inverting buffer with a capacitor between the input and the output. – Connor Wolf Aug 01 '11 at 22:35
  • @FakeName: But where is the inverter? Where is the output that's feeding back to the input? – endolith Aug 02 '11 at 01:05
  • 6
    Basically, **all** IC IO pins go through a buffer (often an inverter) *on the IC Die*. Since the buffer will have wires for the input and output, there can be coupling capacitively between the input and output. Therefore, if the input is sufficiently high impedance, a transition on the inverter output can cause the inverter input to change, causing the output to change again, etc.... – Connor Wolf Aug 02 '11 at 02:07
4

Generally it is a bad idea to leave input pin as floating as this may cause:

a) Functional problems - unknown input state, toggling (for example may trigger interrupt with undefined ISR that would hang processor)

b) Increased power consumption - most likely the input gate is similar to CMOS inverter. With this structure when the input is far enough from either rail (for example at half supply) significant cross over current will flow constantly.

c) If the cross-over current will flow the phenomena know as hot carrier injection may actually decrease lifetime of the device. The input gate may be designed just for normal switching not continuous conduction so device may fail catastrophically. Note however one would need place device in such condition for many hundreds of hours at elevated temperature for this to happen.

Note the a) and b) are real problems that one most likely one will encounter. As for c) it is less likely problem to happen but why take risk?

mazurnification
  • 2,563
  • 1
  • 21
  • 25
3

The input will toggle between 0 and 1 based on any EMI. I'm not sure if it will cause the input to fail, but it will cause more power to be used because the transitions from 0 to 1 to 0.

Set it to an output and be done with it.

Robert Deml
  • 3,232
  • 6
  • 29
  • 27
2

Some high-speed CMOS devices may be destroyed if an input is left floating, but the most common problem one will observe is increased current consumption. On PIC series microcontrollers, the extra current is on the order of hundreds of microamps per floating pin. Not enough to cause device damage, but enough to severely impact battery life in an application that would otherwise draw 5uA. Some chips have options to disable a digital input; if an input is disabled, it may freely be left floating.

supercat
  • 45,939
  • 2
  • 84
  • 143