Embedded HandbookApps
All sections › XVIII. ESP32: the second microcontroller
ESP32, STM32F103, STM32F407 · level intermediate · 7 min read
Open in the interactive handbook

160. Long lines on the board and in wires: characteristic impedance, reflections, termination, the I²C edge

An ESP32 or STM32 pin switches within a few nanoseconds, even if the program toggles it once a second. For such an edge, a trace a few centimeters long or a wire to a sensor is no longer a "conductor" but a line along which the signal travels as a wave and reflects from the end. Hence ringing, false edges on clock inputs, and an I²C bus that works on the bench and fails inside the enclosure.

Here you will find a calculation of a microstrip line on FR-4 (the IPC-2141 formula, microstrip.py) and two ngspice 39 models in the stm-lab:1 image (_verify/esp160/): reflections in a line with and without termination, and the edge of an I²C bus through a pull-up resistor. The model numbers are an idealization: real traces, connectors and chip inputs will give different ones, but the order of magnitude and the conclusions stay the same.

Terms used in the documentation

Term Meaning
transmission line a long line: a conductor along which the signal travels as a wave
characteristic impedance (Z0) the wave impedance of the line
propagation delay the time the signal takes to travel along the line
reflection, ringing, overshoot a wave bounced back, oscillation, a spike above the level
series / parallel termination matching with a resistor at the source / at the end
microstrip a microstrip line: a trace over a solid ground plane
effective permittivity the permittivity the wave actually sees
rise time how long the edge takes to rise
pull-up resistor, bus capacitance a resistor to the supply, the capacitance of the bus

160.1 When a trace becomes a line

A 50 Ω line driven from a pin with a 25 Ω output resistance: without termination the wave doubles at the open end and rings, a parallel 50 Ω resistor at the end kills the reflection, a series 25 Ω resistor at the source gives a clean edge at the receiver

A signal on a trace over a ground plane travels slower than in vacuum: part of the field passes through the fiberglass. For a 50 Ω line on 1.5 mm FR-4 the effective permittivity is 3.385, the speed is 162.9 mm/ns, and the delay is 6.14 ps per millimeter.

A line is considered long when its propagation delay is greater than roughly a sixth of the edge. With a 1 ns edge that is 27 mm of trace, with 5 ns — 136 mm, with 10 ns — 272 mm. The edge of a microcontroller pin is a few nanoseconds, so a half-meter wire to a sensor is always a long line, and a trace on the board becomes one from a few centimeters.


160.2 Characteristic impedance of a microstrip

A trace over a solid ground plane is a microstrip. Its characteristic impedance depends on the trace width w, the dielectric thickness h and the permittivity, not on the length. The IPC-2141 formula for FR-4 with 35 µm copper:

Thickness to ground Trace width Z0
1.5 mm 0.3 mm 124.7 Ω
1.5 mm 1.0 mm 85.0 Ω
1.5 mm 2.729 mm 50 Ω
0.2 mm 0.326 mm 50 Ω

Characteristic impedance of a microstrip on FR-4 versus trace width for two dielectric thicknesses: with 1.5 mm to ground, 0.3 mm gives 124.7 Ω, 1 mm gives 85 Ω, and only 2.729 mm gives 50 Ω; with 0.2 mm, 50 Ω is reached already at 0.326 mm; the formula holds for a width-to-thickness ratio from 0.1 to 2

On a 1.5 mm two-layer board a 50 Ω trace is almost 3 mm wide — that is an antenna feed line, not a signal line. A narrower option is the coplanar line: a trace with a gap to the ground pour on both sides, ground underneath, rows of vias along it. On the same 1.5 mm board a 1.2 mm trace with a 0.2 mm gap gives about 50 Ω — this is how the ESP32 antenna pin is routed to the connector. For many signal lines a pour with gaps is inconvenient, so boards with fast signals are made with four layers: the nearest ground layer is 0.2 mm away, and 50 Ω is reached at a width of 0.326 mm. An ordinary signal trace of 0.3 mm on a two-layer board is about 125 Ω, and you have to terminate it for an impedance you do not know exactly.


160.3 Reflections: a line without termination

The model: a pin with a 25 Ω output resistance drives a 3.3 V edge with a 1 ns rise into a 50 Ω line with a 5 ns delay (about 80 cm of trace); at the end is a chip input, almost an open circuit. Three variants:

case=1 vmax_end=4.39972 vfinal=3.42208 vmax_near=2.19997
case=2 vmax_end=2.19997 vfinal=2.19997 vmax_near=2.19997
case=3 vmax_end=3.29983 vfinal=3.29983 vmax_near=1.64998

Without termination (case=1) a wave of 3.3 × 50 / 75 = 2.2 V enters the line — a divider formed by the output resistance and the characteristic impedance. At the open end it reflects completely and doubles: at the receiver input there are 4.40 V with a 3.3 V supply. The reflection travels back to the source, reflects again from the unmatched 25 Ω — and the line rings: after 29 ns the end still sits at 3.42 V. On a 3.3 V input such an overshoot drives current into the supply through the protection diodes, and ringing around the threshold produces extra edges.


160.4 Termination: parallel and series

Series termination works only for a single receiver at the end of the line: in the middle of the line the level stays at half for some time.


160.5 I²C: the edge is set by the resistor and the capacitance

I²C has no sharp rising edge: the open-drain output releases the line, and it is pulled up by the pull-up resistor, which charges the capacitance of the wires and inputs. The rise time from 30 to 70 % — the way the I²C specification measures it:

Bus capacitance 1.5 kΩ 4.7 kΩ 10 kΩ
100 pF 127 ns 398 ns 848 ns
400 pF 508 ns 1593 ns 3389 ns

The time grows in exact proportion to R·C: 4.7 kΩ × 100 pF = 470 ns, and the 398 ns edge is 470 × ln(7/3). The edge limit is 1000 ns for standard mode and 300 ns for fast mode (section 17). Hence the picture:

Every meter of wire and every device adds capacitance. A long I²C bus is not fixed by "lowering the resistor as far as it goes": the output has a current limit in the low state — per the I²C specification it must hold 0.4 V at 3 mA, hence R ≥ (3.3 − 0.4) / 3 mA ≈ 0.97 kΩ, and the pull-up is not taken below about 1 kΩ (section 17). For meters of wire you use I²C bus buffers or a different interface.


160.6 Pitfalls

Symptom Cause
a clock input catches extra edges the ringing of an unterminated line crosses the threshold
the input sees more than the supply, the chip gets hot the reflection at the open end doubles the wave
with a parallel 50 Ω resistor at the end the logic cannot read a high a divider with the pin's output resistance: the level is below the threshold
a series resistor, and a receiver in the middle of the line fails in the middle of the line the level stays at half for some time
I²C works on the bench, fails in the enclosure on wires the wire capacitance stretches the edge past the mode's limit
fast-mode I²C does not work with modules that have 10 kΩ with such pull-ups the edge is several times longer than 300 ns
a "50 Ω" trace 0.3 mm wide on a two-layer board with 1.5 mm to ground it is about 125 Ω

160.7 Summary

Next: section 161 "Power and loads around the ESP32: the regulator, Wi-Fi peaks, switches, relays and spikes".

Open in the interactive handbook