37
\$\begingroup\$

What does it mean to "tristate a pin" on a CMOS microcontroller?

\$\endgroup\$

2 Answers 2

42
\$\begingroup\$

"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?

\$\endgroup\$
10
  • \$\begingroup\$ Excellent. Glad to be of service. \$\endgroup\$
    – pingswept
    Apr 29, 2010 at 19:52
  • \$\begingroup\$ Not actually the correct answer, see below... \$\endgroup\$
    – ttt
    May 5, 2010 at 9:40
  • 5
    \$\begingroup\$ @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. \$\endgroup\$
    – pingswept
    May 5, 2010 at 14:38
  • 1
    \$\begingroup\$ I'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). \$\endgroup\$
    – ttt
    May 7, 2010 at 14:43
  • \$\begingroup\$ 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. \$\endgroup\$
    – pingswept
    May 7, 2010 at 16:05
17
\$\begingroup\$

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).

\$\endgroup\$
2
  • 1
    \$\begingroup\$ This 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. \$\endgroup\$
    – Frederick
    Jan 20, 2016 at 20:51
  • 1
    \$\begingroup\$ It'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. \$\endgroup\$
    – iheanyi
    Feb 9, 2018 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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