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,581
- 4
- 46
- 64
-
Excellent. Glad to be of service. – pingswept Apr 29 '10 at 19:52
-
Not actually the correct answer, see below... – ttt May 05 '10 at 09:40
-
5@Tim Ring: I think your answer is correct, but I'm not sure where you think I've gone wrong. I understand that "tristate" refers to the ability of a pin to be configurable into three states-- high, low, or high impedance. But in colloquial terms, when someone says "Tristate a pin," they mean to put it into high impedance state. – pingswept May 05 '10 at 14:38
-
1I'm not disputing that the three states are high/low/highZ, I'm saying the bit where you say "if a pin is in high impedance state, it can be pulled to high or low by an external device without much current flow" This is really not the reason, you trisate a device, you deselect it to dis-connect it from the bus (by putting it in a hi-z state other devices can communcate with each other). – ttt May 07 '10 at 14:43
-
Ah, OK, I think I see what you mean. 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:05
-
Yes, tri-state means three states (0, 1, HiZ) and HiZ means it's not asserting 0|1. Using one to mean the other is absolutely wrong. There 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
-
@XTL: I think you're misunderstanding what I wrote. I understand that tri-state means three states. Unfortunately, people regularly use it to mean the HiZ state. As you say, it's absolutely wrong to do so, but I'm trying to explain what people mean when they say "tristate a pin." – pingswept Jul 11 '10 at 14:15
-
I'm confused after reading the conversation and the other answers; is it the case that when a line is set to the HiZ state, that it will not change its state when the line changes? It seems @ttt thinks so, but your answer has made me think otherwise. Can someone clarify? – Klik May 06 '16 at 16:04
-
@Klik it is not the line that is set to a HiZ state but a given IO pin that is connected to the line. When that IO pin is set to the HiZ state, the line can be driven to any state (and will change) based on the actions of other devices. – iheanyi Feb 09 '18 at 16:56
-
One recent issue... "high impedance state" is not equivalent to "infinite impedance". It is HIGH impedance meaning it has some potential to charge/discharge the line capacitance to a voltage between the positive/negative supply rails. So it is incorrect to assume that a line where everything is tri-state will pull to 0V. This will not happen unless the circuit is specifically DESIGNED to do this. – Ross Youngblood Nov 13 '20 at 19:54
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