Skip to main content

Subsection 10.4.10 What Else Open-Drain Buys

Part 6 gave one reason the I2C pins must be open-drain: SDA changes hands every ninth bit, and two push-pull outputs disagreeing about a wire is a short circuit. Two more features of the protocol rest on the same property, and both are worth recognizing even though this course never sets either up.
Sizing the pull-up. Part 6 said the value is squeezed from both ends. Here is the arithmetic, and it is worth seeing that the two ends are not equally tight.
The low end is the sink current. The device pulling the line LOW has to hold it below the receiver’s threshold while the pull-up feeds current into it, and that current is 3.3 V divided by the resistor: 3.3 V through 1 kΩ is 3.3 mA, which most parts manage, and through 200 Ω is 16 mA, which many do not. So the sink current sets a hard floor at somewhere around 1 kΩ, not at 5 kΩ.
The high end is the RC (resistor-capacitor) time constant. Nothing drives the line HIGH; the pull-up charges the bus’s own capacitance, a few hundred picofarads on a short bus, and the line has to get past the receiver’s HIGH threshold, about 0.7 × 3.3 V = 2.3 V, which takes roughly 1.2 time constants. With 300 pF: 5 kΩ gives RC = 1.5 µs and reaches threshold in about 1.8 µs; 10 kΩ gives 3 µs and about 3.6 µs; 20 kΩ gives 6 µs and about 7.2 µs. A 100 kHz clock spends 5 µs LOW, so 5 kΩ is comfortable, 10 kΩ uses most of the window, and 20 kΩ does not make it. That is the ceiling.
So the arithmetic gives a window from about 1 kΩ to about 10 kΩ, and 5 kΩ to 10 kΩ is where designers sit inside it, high enough to keep the current down, and stopping where the RC starts to bite. The convention is a choice within the window rather than the window itself.
The STM32C031C6’s internal pull-ups, about 40 kΩ, sit well above that ceiling, which is why i2c1_init() uses them only as a backstop. With a device attached, the two pull-ups act in parallel: 40 kΩ in parallel with 10 kΩ is 8 kΩ, slightly faster than 10 kΩ alone. With no device attached the bus is only the pins and the board’s traces, a few tens of picofarads: 40 kΩ with 30 pF gives RC = 1.2 µs and reaches threshold in about 1.4 µs, well inside the 5 µs window, which is enough for the address byte and its NACK.
Arbitration. I2C allows more than one controller on a bus. If two of them start a transaction at the same moment, each one watches SDA while it transmits. A controller that releases the line, sending a 1, and then reads it LOW knows that somebody else is pulling it down, which means somebody else is sending a 0 at a bit position where it sent a 1. It has lost, and it stops transmitting immediately. The other controller never notices anything happened. This works only because the combined line reads LOW if any device pulls it LOW, which is the wired-AND behavior open-drain gives you for free.
Clock stretching. SCL is open-drain too, and a target that needs more time can hold it LOW after the controller has released it. The controller’s clock generator waits for the line to actually rise before starting to time the HIGH phase, so the whole bus slows down for as long as the target needs. It is flow control with no protocol overhead at all, one device holding a wire down. RM0490 lists it in the I2C peripheral’s features, and the NOSTRETCH bit in I2C_CR1 is how a target would turn it off.