It’s easy to overlook unused digital inputs when designing with a CMOS device, but doing so invites problems. When unused digital inputs are left unconnected they will float, which can cause both unexpected logic behavior and excessive current draw. Several simple approaches for managing these unused inputs can save significant debugging grief.
Essentially, a CMOS digital input circuit uses MOSFET transistors in pairs (see the figure). Therefore, when the input signal is logical high or logical low, one transistor is on and the other one is off. As a result, CMOS technology only draws current when it’s switching; that is, when one MOSFET is turning on while the other MOSFET is turning off in order to change the output state.
This current draw occurs during the short time needed to charge or discharge each MOSFET’s gate capacitance to effect the state change. During this state change, both MOSFETs are partially on, which creates a path for current from VDD to VSS. Current flowing down through the two MOSFETs in this manner is called “shootthrough” current.
Datasheets typically define voltage ranges for the input signal’s logical high and low, with an undefined region in the middle. Somewhere in this undefined region is the actual change-over voltage at which the circuit will change from seeing one logical input level to the other. The precise change-over voltage is undefined because it ultimately depends on the circuit’s operating voltage, temperature, fabrication geometry, and product batch variation.FLOATING INPUTS A CMOS digital input has a very high impedance. Consequently, when it’s not driven it will float, creating an undetermined input logic level. More importantly, the input may not stay that way and, in fact, it likely will not. For instance, reading the input in software will show a logical high or low, but waving a hand above the circuit board can be enough to cause the input levels to change.
Over time, however, the floating input tends to accumulate a charge and float toward the logiclevel change-over point. When it reaches that point, it causes both the high and low MOSFETs to be partially on, resulting in shootthrough current.
When the input buffer output switches state, the floating input can lose charge, causing the circuit to switch back. This keeps the charge hovering around the change-over point and makes the floating input very susceptible to noise, especially from signals switching on adjacent pins. Engineers need to be especially careful of a floating programming control or reset pins where a nearby toggling line may generate enough noise to make the microcontroller repeatedly drop in and out of programming or reset mode.
A floating input hovering around the change-over point, and thus causing shoot-through current, will cause the CMOS device to exhibit higher than expected power draw. This may not be especially noticeable when the device is running. However, it can be significant for devices such as microcontrollers in their low-power state. In addition, the input’s logic level may change at any time and trigger unexpected responses from the device.AVOID FLOATING INPUTS There are several ways to avoid floating inputs. Many microcontrollers power up their configurable I/O as inputs because the desired output level isn’t initially known. For such devices, simply configure unused pins as outputs and drive them high or low. Make certain that this is done under all paths through the code, though, or there may be one mode where the pin may still be floating.
You could also use external pull-up or pull-down resistors to ensure the states of lines while the device is in reset or the I/O are still being configured. Some chips already incorporate internal pull-up or pull-down circuitry as part of their digital input circuits, so designers can enable this internal termination during device programming or under software control. If internal termination isn’t available, external resistors or resistor networks must be designed in.
An alternative for avoiding floating digital inputs is to connect the pin to VDD or ground. In taking this approach, however, make sure that this pin is never accidentally configured as an output driving the other way. If that were to occur, there would be no limits on the current sourced or sunk, and the device would most likely become damaged.
One additional trick, where available, is to configure unused inputs as analog peripherals, such as comparators or analog-to-digital converters (ADCs). Consequently, the device’s control logic would disconnect the digital input. A floating input simply looks like an ordinary analog voltage to the peripheral, and it won’t cause any adverse effects.