C7 · Lesson 10 · Tri-state and open-drain outputs
Letting several chips share one wire
An ordinary CMOS output always drives its wire: high or low. Connect two such outputs to one wire and, sooner or later, one drives high while the other drives low, and a large current flows from the supply through both to ground. Buses that several chips share need outputs that can step aside. There are two ways to do it: an output that can turn both its transistors off, and one that only ever pulls down.
Play
- The curve is an open-drain bus line rising after the last device lets go: a pull-up resistor charges the bus capacitance.
- Raise the resistor or the capacitance and the edge slows. The marked readout is the 30% to 70% rise time that bus standards specify.
- A smaller resistor speeds the edge, but every device pulling low must then sink more current.
Predict
Two tri-state drivers on a 3.3 V bus are enabled at once by mistake; one drives high and the other low. Each has 50 Ω of on-resistance. What happens?
= 33 mA flows through both outputs, dissipating 0.11 W between them, and the bus sits at an invalid level near the middle. This is bus contention. A moment of it is survivable; sustained, it can damage the drivers. Bus protocols are designed so that at most one driver is ever enabled.
Name it
Tri-state outputs
A tri-state driver has an enable: enabled, it drives 0 or 1 like any output; disabled, both its transistors are off and the output floats in a high-impedance state (Z). Several drivers can share a bus if exactly one is enabled at a time. If none is enabled the bus floats, so it's usually held by a weak pull-up or a bus keeper; if two are enabled with different values, they fight, with a current of .
Open-drain outputs
An open-drain (or open-collector) output has only the pull-down transistor. It can pull the wire low or let go; a pull-up resistor returns it high. Any device pulling low wins, so the line computes the AND of all the devices' outputs, a wired-AND, and there's never contention. Shared interrupt lines, resets and the I²C bus use it.
Choosing the pull-up
When the last device lets go, the line rises as an RC charge, from 30% to 70% of in
A bus standard caps , which caps . Each device must also be able to pull the line below its while sinking the pull-up's current, which sets a minimum:
A smaller gives faster edges but more current and power whenever the line is low.
Worked example
An I²C bus on 3.3 V has 400 pF of capacitance, a 1 µs rise-time limit, and devices that can sink 3 mA at 0.4 V. What pull-up resistors are allowed?
Show the solution
- Rise-time limit.
- Sink-current limit.
- Pick a value. Any value between, such as 2.2 kΩ, works.
- The faster mode. At 200 pF and a 300 ns limit, the maximum drops to 1.77 kΩ, so heavily loaded fast buses need stronger pull-ups or current-source drivers.
Answer anything from 967 Ω to 2.95 kΩ, such as 2.2 kΩ.
Worked example
Three devices share an open-drain interrupt line with a pull-up. Device A outputs 1, B outputs 0, C outputs 1. What does the line read, and what if B lets go?
Show the solution
- B pulls the line low. B's transistor is on, so the line reads 0: a wired-AND.
- B lets go. No device pulls low, and the pull-up returns the line to 1.
- Read it as an interrupt. Read as an active-low interrupt, the line says "someone needs service" whenever any device pulls it, which is exactly what a shared interrupt needs.
Answer the line reads 0, and returns to 1 when B lets go.
Worked example
How much does the contention in the predict cost, and how much does a pull-up of 2.2 kΩ on 3.3 V cost while a device holds the line low?
Show the solution
- Contention. 33 mA flows, and the power is split between the two fighting outputs.
- The pull-up. While the line is low, flows, about 4 mW.
- Compare. The open-drain bus spends a little power continuously in exchange for never fighting.
Answer contention costs 0.11 W (33 mA); the pull-up costs about 4 mW (1.3 mA) while the line is held low.
Check
Two enabled tri-state drivers on a 3.3 V bus fight: one with 20 Ω drives high, the other with 80 Ω drives low.
(a)
What current flows?
Write units the way you normally would: 1.5 mA, 1500 µA and 0.0015 A are the same answer.
(b)
What voltage does the bus sit at?
Check
An open-drain bus on 3.3 V has 100 pF, a 1 µs rise-time limit, and devices that sink 20 mA at 0.4 V.
(a)
What's the largest pull-up?
Write units the way you normally would: 1.5 kΩ, 1500 Ω and 0.0015 MΩ are the same answer.
(b)
What's the smallest?
Check
Three open-drain outputs A, B and C share a line with a pull-up. Write the line's value.
Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.
Check
What's the 30% to 70% rise time of an open-drain line with a 2.2 kΩ pull-up and 50 pF?
Write units the way you normally would: 1.5 ns, 1500 ps and 0.0015 µs are the same answer.
Check
Several chips share a bus where any of them may need to signal a fault at any moment, without coordination. Which output type should drive it?
Check
Write pullup_range(V, C, tr, Vol, Iol) returning (Rmin, Rmax) in ohms for an open-drain bus: the smallest pull-up the drivers can overcome and the largest that meets the 30% to 70% rise time tr.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
Why can't two ordinary CMOS outputs share a wire, while two open-drain outputs can?
An ordinary CMOS output always connects its wire either to the supply or to ground through a transistor. If two such outputs disagree, one connects the wire to the supply and the other to ground, so current flows straight through both transistors, wasting power and leaving the wire at an invalid voltage in between. An open-drain output can only connect the wire to ground or let go; nothing in it ever drives the wire high. A shared pull-up resistor does that, weakly. When several open-drain outputs disagree, the ones pulling low simply win against the resistor, with only the resistor's small current flowing, so the wire reads the AND of all the outputs and nothing fights.
Practice
Keep practicing
5 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.