30
\$\begingroup\$

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.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – XTL
    Nov 28 '10 at 10:50
  • \$\begingroup\$ @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. \$\endgroup\$
    – Thomas O
    Nov 28 '10 at 10:52
  • \$\begingroup\$ There's a difference between a floating digital input and an input defined as analogue. Sounds like this is an analogue input. \$\endgroup\$
    – Martin
    Nov 29 '10 at 13:13
  • \$\begingroup\$ @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. \$\endgroup\$
    – Thomas O
    Nov 29 '10 at 13:16
  • 2
    \$\begingroup\$ What MCU are you using that defaults all pins to output? That sounds like a recipe for disaster. \$\endgroup\$ Aug 1 '11 at 22:34
33
\$\begingroup\$

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.

\$\endgroup\$
9
  • 3
    \$\begingroup\$ 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? \$\endgroup\$
    – endolith
    Nov 27 '10 at 3:12
  • 3
    \$\begingroup\$ If I'm ignoring the pin and not using it for any peripherals would it still cause problems? \$\endgroup\$
    – Thomas O
    Nov 27 '10 at 10:04
  • \$\begingroup\$ @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! \$\endgroup\$ Nov 28 '10 at 22:31
  • 2
    \$\begingroup\$ 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? \$\endgroup\$
    – endolith
    Nov 30 '10 at 15:22
  • \$\begingroup\$ TIL floating pins aren't harmless. Thanks IntelliChick and @Yann! \$\endgroup\$ Aug 2 '11 at 1:31
13
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ The inputs don't have hysteresis? \$\endgroup\$
    – endolith
    Nov 29 '10 at 5:38
  • 3
    \$\begingroup\$ Schmitt trigger inputs do, but generally, no. \$\endgroup\$ Nov 29 '10 at 6:59
6
\$\begingroup\$

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)

\$\endgroup\$
4
  • \$\begingroup\$ What exactly would oscillate, and why? \$\endgroup\$
    – endolith
    Nov 30 '10 at 15:22
  • \$\begingroup\$ @endolith - The input buffer on the pin. Think about a inverting buffer with a capacitor between the input and the output. \$\endgroup\$ Aug 1 '11 at 22:35
  • \$\begingroup\$ @FakeName: But where is the inverter? Where is the output that's feeding back to the input? \$\endgroup\$
    – endolith
    Aug 2 '11 at 1:05
  • 3
    \$\begingroup\$ 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.... \$\endgroup\$ Aug 2 '11 at 2:07
4
\$\begingroup\$

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?

\$\endgroup\$
3
\$\begingroup\$

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.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ If I set it to an output, 0 or 1, it will ground out the video signal and cause a loss of video. \$\endgroup\$
    – Thomas O
    Nov 27 '10 at 10:05
  • \$\begingroup\$ Can you enable an internal pull-up and be done with it? \$\endgroup\$
    – endolith
    Nov 30 '10 at 15:23
  • \$\begingroup\$ Enabling the internal pull-up should be good. The point is to put it into a known state and leave it there. \$\endgroup\$
    – Robert
    Nov 30 '10 at 16:14
2
\$\begingroup\$

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.