Microcontroller Output Modes: Open Drain and Push Pull

A microcontroller pin is not a switch. It is a driver with a defined output stage, and whether that stage can pull the line high, sink it low or only do one of the two decides how the net is wired, how fast it switches and what happens when two devices share it.

The Two Output Structures

A push pull output contains two transistors in series between the supply and ground. When the pin is driven high one device is on, when it is driven low the other is, and the line is actively held at each level.

An open drain output contains only the lower device. When it is on the pin is pulled to ground, and when it is off the pin is left floating, so the high level has to be produced by something external.

What Open Drain Cannot Do

An open drain pin cannot source current. Its high state is the absence of a low state, and without an external pull up resistor the line will simply float and read whatever noise it collects.

That is why every open drain net has a resistor to a supply rail, and why the value of that resistor is part of the design rather than a default on a schematic. Without it, a bus that works on the bench will fail as soon as the cable is attached.

Open drain and push pull output stage circuits

Sizing the Pull Up

The resistor is a compromise between speed and current. A small value charges the line capacitance quickly and gives sharp edges but draws current continuously whenever the pin is low, while a large value saves power and slows the transition.

The limit in the other direction is the sink current the device can accept. The resistor has to be large enough that the pin, when it pulls the line low, is not asked to carry more current than the datasheet allows.

Wired Logic and Shared Buses

Open drain outputs can be connected together without conflict, because any one of them can pull the line low and none of them can drive it high. The result is a logical AND of all the outputs, which is why the arrangement is called wired logic.

This is what makes a bus such as I2C possible. The clock and data lines are open drain, pulled up by resistors, and a device that wants to hold the line asserts it by pulling low. The same structure supports multi master arbitration.

Level Translation With an Open Drain Pin

Because the high level comes from the pull up resistor, it can be set by choosing which rail the resistor connects to. A device supplied from a low voltage rail can therefore drive a line that swings to a higher level, provided the pin tolerates that voltage.

The pin voltage rating is a hard limit. A device whose pin is rated for a lower supply will be damaged if the resistor pulls it above that value, and a series arrangement or a dedicated level shifter is needed instead.

Pull up resistors on a shared I2C bus on a PCB

Push Pull Behaviour and Its Risks

A push pull output drives the line in both directions, which gives fast edges and no static current at either level. It is the correct choice for a point to point signal that only one device drives.

It is the wrong choice for a shared line. If two push pull outputs are connected and one drives high while the other drives low, a low resistance path is formed between the supply and ground and a large current flows through both output stages.

Drive Strength and Slew Control

Modern controllers let the drive strength of a pin be selected in software or by configuration. A stronger driver produces faster edges, which is desirable for a clock and undesirable for a signal that radiates or rings.

Where a pin drives a long trace or a capacitive load, the weaker setting with a series resistor often gives a better eye than the strongest setting without one. The edge rate is the variable that decides the emission, so it is worth controlling deliberately.

Unused Pins and Their State

A pin configured as an input with no connection is a floating node that can sit at any voltage and draw current through the input stage. The usual practice is to configure unused pins as outputs driven low, or to fit a pull resistor, rather than to leave them open.

On a bus, an unused pin should be left in the high impedance state so that it does not interfere with the devices that are communicating. The difference between these two cases is a decision about the firmware as much as about the schematic.

Practical Design Rules

Use open drain where the line is shared or where a level shift is needed, and push pull where one device owns the net. Put the pull up resistors near the point where the line impedance is lowest rather than at the far end of the bus.

Keep the stubs on a bus short, and route the pull up in a way that does not create a long branch. The fanout rules for the package and the current capability of the trace are the two checks that follow from the choice of output mode.

Testing the Interface

A shared bus is best checked with a scope at the slowest and the fastest corner of the design. Rise time, noise margin and the behaviour when two devices assert at once are all visible there, and none of them can be checked with a logic analyser alone.

Where a bus fails intermittently, the cause is usually the pull up value, the trace capacitance or a device that is holding the line longer than the protocol allows. Measuring the actual rise time is the fastest way to separate those three cases.

Process Control and Verification

On a design of this kind, bus is the item that decides how the rest of the board is arranged. Where the requirement is not written down, the shop supplies its own default, and the default is chosen for the process rather than for the design. The measurements that matter are the repeatable ones: conductor width and spacing, annular ring, finished hole size, plating thickness and surface finish are all verifiable on a coupon that travels with the panel.

Running a first article through the same checks as the production panel confirms that the two agree, and that comparison is the cheapest form of process control available at prototype stage.

Process Control and Verification

On a design of this kind, bus is the item that decides how the rest of the board is arranged. Where the requirement is not written down, the shop supplies its own default, and the default is chosen for the process rather than for the design. The measurements that matter are the repeatable ones: conductor width and spacing, annular ring, finished hole size, plating thickness and surface finish are all verifiable on a coupon that travels with the panel.

FAQ

Why does an open drain line need a resistor? Because the pin cannot produce a high level. Without a pull up, the line floats whenever no device is pulling it low.

Can two push pull outputs share a line? Not safely. If they disagree, the two output stages form a short circuit through the devices, and one of them can be destroyed. The pad and net standards for the package do not change that.

How is the pull up value chosen? From the rise time the bus requires and the sink current the device allows, checked at the worst case capacitance of the longest bus configuration.

Leave A Comment