Electronic – I2C pull-up resistors calculation & where to place them


I'm connecting a PIC18F46K22 (master) to a PIC18F4620 (slave) using I2C. The wire between the devices is ~30cm. I'm using 400kHz without slew rate control. Later on, I'll add another 18F4620 on ~5cm from the master (~35cm from the other slave).

How do I calculate the pull-up resistance needed on both the SCL as the SDA line?

Does it matter where I place the pull-up (near the master, near the slave, both, in the middle, …)?

Best Answer

The pull-ups are generally located near the master device.

This app note goes into some of the calculations. Essentially, the size of the pull-up will be defined by the total bus capacitance and the pull-down capabilities of the devices on the bus:

\$ R_p \ge \dfrac{V_{dd}-V_{OL}}{I_{OL}}\$


\$ R_p \le \dfrac{300ns}{0.847298 \times C_{bus}}\$

where \$V_{OL}\$ is the logic low voltage needed, \$I_{OL}\$ is the sinking current, and \$C_{bus}\$ is the bus capacitance.

Of course, once your sample is built, the best thing to do is scope the waveforms and make whatever adjustments are needed.