TDEB Top Bar

Trending
Semiconductor Industry News — The Digital Electronics Blog
Follow Us

TDEB Masthead

The Semiconductor Hub

Semiconductors.  Chips and Systems.  Innovation.

Indexed by leading Search Engines, AI and referenced by Engineers worldwide 500+ Articles 10M+ Pageviews 30+ Reports 50+ Citations

I2C Bus: An Introduction to the Two-Wire Control Bus

The Editor's Desk
by
1
Share Facebook X LinkedIn WhatsApp Email

The Inter-IC bus, commonly known as the I²C ("eye-squared-see") bus, is a control bus that provides the communications link between integrated circuits in a system. Developed by Philips in the early 1980s, this simple two-wire bus with a software-defined protocol has evolved to become the de facto worldwide standard for system control, finding its way into everything from temperature sensors and voltage level translators to EEPROMs, general-purpose I/O, A/D and D/A converters, CODECs, and microprocessors of all kinds.

The original 2005 post linked to a Philips Semiconductors fact page that no longer exists. Philips Semiconductors is now NXP, and the official reference today is the NXP I²C-bus specification and user manual, UM10204 (Rev. 7.0, October 1, 2021). This post explains the bus in outline, then works through the electrical and timing numbers from that specification.

How I²C works, in outline

I²C uses two wires shared by every device on the bus:

  • SCL, the serial clock, driven by the controller (the specification's term for what older texts call the master).
  • SDA, the serial data line, driven by whichever device is sending at the moment.

Both lines are open-drain. A device can only pull a line low; a pull-up resistor pulls it high when nobody is driving. This "wired-AND" arrangement is what lets many devices share two wires without fighting, and it lets parts with different supply voltages coexist.

Every device has an address, usually 7 bits. The controller starts a transfer, sends the address of the target (formerly "slave") and a read or write bit, and the addressed device answers with an acknowledge bit. Data then moves in 8-bit bytes, each followed by an acknowledge, until the controller ends the transfer.

Why it became the standard

  • Two pins: a microcontroller can talk to dozens of chips without spending pins on chip selects.
  • Addressing in the protocol: adding a device means connecting it to the same two wires.
  • Multi-controller support: collision detection and arbitration let more than one controller share the bus.
  • Software friendly: transfers are simple byte sequences, so even a bit-banged GPIO driver works.

When to use it, and when not

I²C is ideal for configuration and slow data: reading a temperature sensor, setting a PMIC voltage, loading a codec's registers, reading a board ID EEPROM. It is a poor fit for streaming data such as audio samples, images or flash memory images, where SPI or a dedicated interface is much faster. It is also meant for short distances on one board or between nearby boards, because bus capacitance limits speed.

Deep dive: the numbers and details

This part holds the speed modes, frame format, pull-up resistor equations and a worked example, all from UM10204 Rev. 7.0. Skip it if the overview is all you need.

Speed modes

ModeMaximum bit rateDirection
Standard-mode (Sm)100 kbit/sBidirectional
Fast-mode (Fm)400 kbit/sBidirectional
Fast-mode Plus (Fm+)1 Mbit/sBidirectional
High-speed mode (Hs)3.4 Mbit/sBidirectional
Ultra Fast-mode (UFm)5 Mbit/sUnidirectional (writes only)

Frame format

  • START (S): SDA falls while SCL is high. STOP (P): SDA rises while SCL is high. These are the only times SDA may change while SCL is high; normal data changes only while SCL is low.
  • Address byte: 7 address bits plus a read/write bit (0 = write, 1 = read).
  • Acknowledge: on the ninth clock the receiver pulls SDA low (ACK). Leaving it high is a NACK, used by a controller-receiver to signal the last byte, or by a target that is absent or busy.
  • Repeated START (Sr): lets the controller change direction without releasing the bus, the usual way to write a register pointer and then read from it.

Overhead: each byte costs 9 clocks (8 data plus ACK). Reading 2 bytes from a sensor register with a write of the register pointer, a repeated START and a read takes S + 9 (address, write) + 9 (register) + Sr + 9 (address, read) + 18 (two data bytes) + P, about 46 clocks. At 400 kHz that is roughly 115 μs for 16 bits of payload.

Reserved addresses

Two groups of eight 7-bit addresses, 0000 XXX and 1111 XXX, are reserved (UM10204 section 3.1.12). They include the general call address (0000 000 with write), the START byte, the Hs-mode controller code (0000 1XX), the device ID (1111 1XX) and the 10-bit addressing prefix (1111 0XX). That leaves 112 usable 7-bit addresses. 10-bit addressing (section 3.1.11) extends the space and can share the bus with 7-bit devices.

Clock stretching and arbitration

A target that needs more time can hold SCL low after a byte; the controller waits until SCL is released (section 3.1.9). Clock stretching is optional and some controllers do not support it, which is a frequent cause of "the sensor works on one board but not another".

When two controllers start at once, arbitration proceeds bit by bit on SDA (section 3.1.8). A controller that sends a 1 but sees a 0 knows another controller is driving and backs off. Because the winning controller's data is what everyone saw, no information is lost.

Key timing and electrical limits

ParameterStandard-modeFast-modeFast-mode Plus
SCL low period tLOW (min)4.7 μs1.3 μs0.5 μs
SCL high period tHIGH (min)4.0 μs0.6 μs0.26 μs
Data set-up time tSU;DAT (min)250 ns100 ns50 ns
Rise time tr (max)1000 ns300 ns120 ns
Bus capacitance Cb (max)400 pF400 pF550 pF
Low-level output current IOL at VOL = 0.4 V (min)3 mA3 mA20 mA

Sizing the pull-up resistor

The pull-up must be small enough for the line to rise in time, and large enough that a driver can pull it low (UM10204 section 7.1; see also TI application note SLVA689, I²C Bus Pullup Resistor Calculation).

Rp(min) = (VDD - VOL(max)) / IOL

Rp(max) = tr / (0.8473 x Cb)

The 0.8473 factor is the time for an RC charge to go from 0.3 VDD to 0.7 VDD, the input thresholds: t2 - t1 = RC ln(0.7/0.3) = (1.2040 - 0.3567) RC = 0.8473 RC.

Worked example

A Fast-mode bus at VDD = 3.3 V with an estimated Cb of 200 pF (traces, connectors and ten device pins):

  • Rp(min) = (3.3 - 0.4) / 3 mA = 967 Ω.
  • Rp(max) = 300 ns / (0.8473 x 200 pF) = 1.77 kΩ.
  • Choose a standard value between them, for example 1.5 kΩ. Rise time = 0.8473 x 1.5 kΩ x 200 pF = 254 ns, inside the 300 ns limit.

The same bus in Standard-mode (tr = 1000 ns) allows up to 5.9 kΩ, which is why 4.7 kΩ works at 100 kHz but often fails at 400 kHz.

Common mistakes

  • Pull-ups that are too weak for the speed and bus capacitance, giving slow, rounded edges.
  • Two devices with the same fixed address on one bus. Use address pins, a second bus or an I²C multiplexer.
  • Forgetting that the address in a datasheet may be given as an 8-bit value with the read/write bit included.
  • A bus stuck low after a reset in the middle of a transfer. The usual recovery is to clock SCL up to nine times until the target releases SDA, then send a STOP.

Interview angle

Typical questions: why I²C lines are open-drain; how arbitration works without losing data; how to calculate the pull-up range; what clock stretching is; and how many devices fit on a bus (limited by addresses and by the 400 pF capacitance, whichever comes first).

Further reading

The Editor's Desk
About the Author
The Editor's Desk
Share Facebook X LinkedIn WhatsApp Email

Post a Comment

1 Comments

Your comments will be moderated before it appears here.

Post a Comment

#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Learn more
Ok, Go it!