Electronics & Circuits · Study deck

GPIO Output Stage Contracts

Picture a sensor board and an add-on board sharing one alert line.

Voltage Vera is your guide for this deck.

gpiooutputstage
Voltage Vera, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Distinguish push-pull outputs from open-drain/open-collector outputs at the transistor-stage level.
  • Choose push-pull or open-drain behavior for SPI, PWM, chip-select, I2C, shared interrupt, and cross-rail interface lines.
  • Explain how a pull-up resistor defines the HIGH level and why the resulting edge is slower than an actively driven HIGH.
  • Identify bus-contention failure modes when multiple push-pull outputs are tied together.
iotclass.org

Major section

Start Simple

If both sides drive opposite levels, the logic trace may look odd while excess current stresses the parts.

  • GPIO means a general-purpose input/output pin.
  • I2C is a shared two-wire link whose devices normally pull lines low and let resistors raise them.
  • SPI is a clocked link with separate driven data paths.
  • PWM is its short name.
iotclass.org

Major section

Start Simple (continued)

Pulse-width modulation means carrying an output setting in the on-time share of a switching signal.

  • This runway does not select a resistor or prove electrical ratings.
  • The deeper sections compare push-pull and open-drain stages, edge timing, contention, shared lines, and the release checks for each use.
  • GPIO output stages define whether a pin actively drives both directions, only pulls LOW, or must rely on a resistor.
iotclass.org

Major section

Overview: Two Ways an Output Stage Drives a Pin

The transistors at an output pin are wired in one of two ways, and the choice decides how the pin can be used.

  • The easiest way to read a schematic is to ask who owns the wire in each state.
  • The default for ordinary signals (SPI, PWM, chip-selects).

Why it matters

For a private LED, chip-select, enable pin, or MOSFET gate, the board usually wants a decisive HIGH and LOW, so push-pull is the normal contract.

An I2C bus is the familiar open-drain case: every device can pull SDA or SCL LOW, but the pull-up resistors define the released HIGH level for the shared wires.
An I2C bus is the familiar open-drain case: every device can pull SDA or SCL LOW, but the pull-up resistors define the released HIGH level for the shared wires.
iotclass.org

Major section

Overview: Two Ways an Output Stage Drives a Pin (continued)

A push-pull output owns the wire all the time: HIGH is an active source path and LOW is an active sink path.

  • That difference is why push-pull suits private, point-to-point outputs, while open-drain suits shared or active-LOW signals.
  • The labelled progression means an I2C bus is the familiar open-drain case: every device can pull SDA or SCL LOW, but the pull-up resistors define the released HIGH level for the shared wires.
  • When the low-side transistor turns on, the pin is strongly connected to ground and can sink current.
iotclass.org

Major section

Overview: Two Ways an Output Stage Drives a Pin (continued)

For overview: two ways an output stage drives a pin, that order identifies what to measure or calculate before accepting the hardware choice.

  • Level flexibility An open-drain line's pull-up can go to any allowed rail, setting the HIGH voltage independent of the chip's own Vcc.
  • For I2C, shared interrupt lines, reset aggregators, fault outputs, and presence-detect pins, the board often wants several devices to share one wire without coordinating who may talk first.
  • When it turns off, the pin becomes high impedance and needs the external circuit to define the voltage.
iotclass.org

Major section

Practitioner: Which Stage for Which Job

A small resistor gives a faster rise but wastes more current whenever any device pulls LOW.

  • It gives clean, quick edges in both directions.
  • A transistor low-side load switch is the same idea in power form: the MOSFET pulls the load's return to ground while the load's other end sits at the supply.
  • Without those checks, "open-drain" is only a schematic label, not a verified interface.

Why it matters

The load sees supply voltage because its other side is tied to the positive rail, not because the microcontroller pin provides load power.

iotclass.org

Major section

Practitioner: Which Stage for Which Job (continued)

If two chips both default to push-pull output while their firmware is still starting, the schematic may be unsafe even if the application code later avoids simultaneous drive.

  • The GPIO only has to swing the gate; the drain switches the 12 V load the pin could never drive directly.
  • A large resistor saves current but may rise too slowly or lose noise margin when leakage, long cables, ESD structures, or unpowered devices load the bus.
  • The design review should name the rail, the resistor value, the expected line capacitance, the required rise time, and the worst-case LOW sink current.
iotclass.org

Major section

Under the Hood: Bus Contention and the Passive-Edge Cost

The contention current can be much larger than the normal load current because both output transistors are turned on hard.

  • The danger open-drain avoids is bus contention.
  • Large current flows, the logic level is ambiguous, and the output transistors can be damaged.
  • That safety has a price.
iotclass.org

Deck summary

Key takeaways

If both sides drive opposite levels, the logic trace may look odd while excess current stresses the parts.

  • Pulse-width modulation means carrying an output setting in the on-time share of a switching signal.
  • The transistors at an output pin are wired in one of two ways, and the choice decides how the pin can be used.
  • A push-pull output owns the wire all the time: HIGH is an active source path and LOW is an active sink path.
  • For overview: two ways an output stage drives a pin, that order identifies what to measure or calculate before accepting the hardware choice.
iotclass.org

Retrieval practice

Recall check 1 of 3

Voltage Vera says: answer from memory, then check your reasoning.

Q1What can an open-drain output do on its own, and what does it require to produce a HIGH?

AIt can only pull the line LOW (or release it to high-impedance).
BIt actively drives both HIGH and LOW with no external parts.
CIt can only drive HIGH and needs a pull-down for LOW.
DIt outputs an analog voltage set by the gate.
Show answer

Answer: A Open-drain has just the low-side transistor, so it sinks LOW or releases; the HIGH comes from an external pull-up to the chosen rail.

iotclass.org

Retrieval practice

Recall check 2 of 3

Voltage Vera says: answer from memory, then check your reasoning.

Q2Why is I2C defined with open-drain outputs and pull-up resistors rather than push-pull drivers?

AIt lets any device pull LOW while no device drives HIGH into another.
BBecause push-pull cannot switch fast enough for I2C speeds.
CBecause open-drain uses less board space by needing more resistors.
DBecause I2C carries analog signals that push-pull cannot handle.
Show answer

Answer: A Open-drain lets devices only pull low or release, enabling multiple devices, acknowledgements, and multi-master on shared lines without two drivers fighting.

iotclass.org

Retrieval practice

Recall check 3 of 3

Voltage Vera says: answer from memory, then check your reasoning.

Q3Two push-pull outputs are accidentally wired to the same line; one drives HIGH and the other LOW. What happens, and why does open-drain avoid it?

AA low-resistance path forms from Vcc through both output stages to GND
BNothing happens; the line simply settles at the average voltage.
CThe HIGH driver always wins with no extra current.
DOpen-drain avoids it by driving HIGH faster than push-pull.
Show answer

Answer: A Two opposing push-pull drivers short the rails through their output transistors, drawing large current and risking damage.

iotclass.org

Print reference

Answers

Answer key.

  1. A · Open-drain has just the low-side transistor, so it sinks LOW or releases; the HIGH comes from an external pull-up to the chosen rail.
  2. A · Open-drain lets devices only pull low or release, enabling multiple devices, acknowledgements, and multi-master on shared lines without two drivers fighting.
  3. A · Two opposing push-pull drivers short the rails through their output transistors, drawing large current and risking damage.
iotclass.org