Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

The datasheet of the 24LC256 EEPROM states that:

The SDA bus requires a pull-up resistor to VCC (typical 10 kΩ for 100 kHz, 2 kΩ for 400 kHz and 1 MHz).

I thought that any resistor with a kΩ value would do the job (and it seems that my EEPROM works fine at different frequencies with a 10 kΩ resistor).

My questions are:

  • is there a correct value for pull-up resistors ?
  • is there a law/rule to determine this value ?
  • how do different resistance values affect the I²C data bus ?
share|improve this question
    
Somewhat related: electronics.stackexchange.com/q/76376/2028 –  JYelton Jan 6 at 16:54
add comment

5 Answers 5

up vote 21 down vote accepted

The correct pullup resistance for the I2C bus depends on the total capacitance on the bus and the frequency you want to operate the bus at.

The formula from the ATmega168 datasheet (which I believe comes from the official I2C spec) is --

$$Freq<100kHz \implies R_{min}=\frac{V_{cc}-0.4V}{3mA}, R_{max}=\frac{1000ns}{C_{bus}}$$

$$Freq>100kHz \implies R_{min}=\frac{V_{cc}-0.4V}{3mA}, R_{max}=\frac{300ns}{C_{bus}}$$

The Microchip 24LC256 specifies a maximum pin capacitance of 10pF (which is fairly typical). Count up the number of devices you have in parallel on the bus and use the formula above to calculate a range of values that will work.

If you are powering off of batteries I would use values that are at the high end of the range. If there are no power limits on the power source or power dissipation issues in the ICs I would use values on the lower end of the range.

I sell some kits with an I2C RTC (DS1337). I include 4K7 resistors in the kit which seems like a reasonable compromise for most users.

share|improve this answer
    
Typically I would imagine the bus to be idle (de-asserted) the vast majority of the time, so for a battery application there are more important issues to deal with than trying to optimize I2C pullups just so :P –  Nick T Oct 2 '10 at 3:02
    
only thing i would add is a buffer above the summed capacitance of the devices on the bus. The trace itself as well as the solder joints from pads to pins will also have some impedance. On longer buses the capacitance of the trace/wire can be larger than the pin capacitance of the devices. When designing production boards i don't usually determine the final pull up value till i have a prototype in hand and can scope the bus with various values. –  Mark Oct 4 '10 at 2:01
add comment

For low frequencies the value doesn't really matter, but for high frequencies it can have a filtering effect on the signal, in combination with other capacitances in the circuit, which is why they recommend different values for different speeds.

share|improve this answer
add comment

Low pull-up values (lower resistance) can improve the edges of the signal transitions but can sometimes be too stiff - if the devices on the bus cannot sink the pull-up current you get logic 'low' which isn't really that low, which can cause communication errors (and much pain.)

I would go with the highest pull-up resistance that gives you reliable communications.

share|improve this answer
add comment

There is a correct range of values, however it is difficult to describe exactly what that range is. Generally, 10k works.

Digital outputs have a specified ability to source or sink current. If your output could sink 5 mA and the output was connected through a pull-up to 5 V and then set to 0, you would need a minimum of 1k resistance. If you use less than 1k, the output will not be able to sink enough current to pull the pin all the way down to 0V. If you use a bigger value, like 10k, then the pin only has to sink 0.5 mA, which is much less than it's rating.

Digital inputs have a specified leakage current. This is kinda like the amount of current it takes to "maintain" a 0 or 1 at an input. If your pull-up resistor is too large, then it won't be able to overcome the leakage current. If it just barely overcomes the leakage current, then any noise in the circuit could be enough to change the input.

When using digital outputs that can sink and source current ("totem pole driver", "push-pull driver"), you might be tempted to not use pull-up or pull-down resistors. However, it is very important that CMOS inputs not be allowed to float or they can pull excessive current...and it's very easy to forget that bidirectional MCU pins usually come up as inputs!


I2C and other protocols like it use "open drain" (or "open collector") outputs. Instead of having outputs that can pull up and down, and open drain outputs can only pull down. That is why the external pull-up resistor is required. There are now additional restrictions on the range of pull-up resistors; the pull-up value will form an RC circuit with the bus capacitance. Too small of a value will once again prevent the output drivers from sinking enough current to pull the pin all the way down to 0. However, too large a value will take too long to charge the bus capacitance up.

If there are setup/hold times that you are not allowed to violate, those will help you determine an RC time constant. The bus capacitance is largely determined by PCB layout, so you can then pick an R value that combines with the C to provide a value that is comfortably within the setup/hold time for your digital input.

share|improve this answer
add comment

It makes sense that higher frequencies require lower resistance pull-ups: a lower resistance will charge/discharge the cable's capacitance faster, which results in steeper edges. With the wider pulses of lower frequencies a less steep edge won't influence the pulse's shape as much.

Therefore the I2C specification gives maximum values for the pull-up resistors as a function of bus capacitance for three speed classes:

enter image description here

The minimum values are defined in function of the bus voltage, and should limit the current through the drivers.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.