What does it mean to "tristate a pin" on a CMOS microcontroller?
2 Answers
"Tristate" means a state of high impedance. A pin can either pull to 0 V (sinking current, generally), pull to 5 V (sourcing current, generally), or become high impedance, like an input.
The idea is that if a pin is in high impedance state, it can be pulled to high or low by an external device without much current flow. You see this kind of thing on bidirectional serial lines, where sometimes a pin is an output and sometimes an input. When it's an input, it's "tristated," allowing the external chip to control its logic level.
Does that make sense in your situation?
- 12,651
- 4
- 46
- 66
The idea of tri-state is to allow multiple output devices to share a single bus. For example, multiple RAM/ROM chips can be connected to a data bus. Only the selected chip will have active outputs (high or low), the other chips (not selected) will have all their outputs set to the hi impedence state (the third state). For outputs devices to share a bus they must be tri-state capable (usually controlled by chip-enable/direction pins). For microprocessors, micro controllers their hi impendence state allows other devices to use the bus (common for smart I/O devices, DMA etc).
- 658
- 1
- 6
- 10
-
1This answer adds is an explanation of why it is called "tri-state." (bc it is the "third state") and a bit of history. It is not more correct than the other answer. – Frederick Jan 20 '16 at 20:51
-
1It's not just for devices to share a bus. I may want to selectively divide down a reference voltage. Using a high-z pin on the low side lets me drive it low and create a voltage divider or high impedance and allow the reference to pass thru. It's pretty much to allow you to selectively disconnect something from a circuit, whether it's digital or analog, communications or not. – iheanyi Feb 09 '18 at 16:58
I agree that in the multidrop bus situation you describe, the point of the hi-Z state is not limiting current flow, but to allow another device to control the pin state, like you say. But there are times, other than the bus situation, where you might use a pin as an output some of the time, but use it as a high impedance input the rest of the time.
– pingswept May 07 '10 at 16:05There are actually cases where you can "tristate a pin". For example, an AVR gpio pin can be configured to work in various modes. Some operations will make it a tristate pin, some open drain and some push-pull 0|1.
– XTL Jul 11 '10 at 08:37