Settings

Theme

Internal pull-up resistors are insufficient for I2C

joshmcguigan.com

14 points by JoshMcguigan 3 years ago · 10 comments

Reader

JoshMcguiganOP 3 years ago

I was using I2C for the first time, as part of a brushess ESC project, and had to learn the hard way that internal (to the mcu) pull-up resistors would not work at any reasonable (for my needs) communication speed.

This post compares the performance of the circuit using the internal pull-up resistors against external 1kohm resistors, including plots showing the improved signal quality.

  • bjt2n3904 3 years ago

    Do any math to see what the internal pull ups and bus capacitance were? What MCU?

pie314isi 3 years ago

Sometimes you can get away with just guessing pull-ups, but sometimes you need to calculate them. Drive strength, speed, line capacitance, line length, number of devices, supply voltage, threshold levels... it's all stuff you take into account when designing for I2C properly.

Reading the datasheets for both devices would probably avoid the problem.

thinknubpad 3 years ago

Anecdata: seems like internal pullups are usually 10s of kΩs, maybe 20-50kΩ. Most sensor boards that I see use 4.7kΩ, and work with 400KHz-1MHz "fast-mode+".

So 1kΩ is safe, but might be a bit on the aggressive side. At 3.3V, 1KΩ to ground burns 3.3mA, and there are two pull-ups per I2C bus.

  • synack 3 years ago

    The I2C spec gives you a minimum and maximum rise time, but does not specify resistor values. Those values should be selected based on the total capacitance of the bus to meet the rise time requirement, either calculated or measured.

    The I2C specification is full of these kinds of ambiguities, which creates a lot more work for implementers. SMBus's physical layer is a subset of I2C that tightens these requirements and specifies pull-up current, making these calculations quite a bit easier.

    http://www.smbus.org/specs/SMBus_3_2_20220112.pdf

  • bjt2n3904 3 years ago

    Yep, this post checks out.

    If you're doing coin cell powered stuff, those brief 3.3 mA pulses can really chew up your battery life.

scotty79 3 years ago

Recently I investigated how to use MCP23017 to have a lot of GPIO pins (to interface with old laptop keyboard).

It seems that pulling up I2C pins with 4.7kOhm resistors is a way to go:

https://tronixstuff.com/2011/08/26/arduino-mcp23017-tutorial...

Ccecil 3 years ago

This actually just bit us on a project recently that has a comparator with an open drain output. STM32H7 internal pullups are in the area of 40k ohm. Datasheet for the comparator called for 1-10k ohm.

I can absolutely see I2C having issues even more...but for different reasons.

jrexilius 3 years ago

I've gone back and forth on using external resistors for I2C and have read a lot of conflicting views on it. I think this is another to add to the pile, but I'm leaning towards putting them on PCB designs by default now..

  • adamrmcd 3 years ago

    I am not an expert, but I think it depends on your MCU. (Some may have better implementation of a soft-pull-up than others.)

    I've only implemented i2c on esp32-s2, and left the pullup footprints unpopulated at first. Eventually I came to the same conclusion and put two 10k resistors on and called it a day. Cost was negligible.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection