I2C pullups - are they always necessary?

86 views
Skip to first unread message

Quixotic Nixotic

unread,
Apr 15, 2012, 12:50:43 PM4/15/12
to neoni...@googlegroups.com
I am driving a DS3231 I2C clock from a PIC's pins. If the logic state of the pins is always high or low, do I really need pullups on the bus? The only reason I ask is that space is at a premium.

Adam Jacobs

unread,
Apr 15, 2012, 12:53:10 PM4/15/12
to neoni...@googlegroups.com
Yes, those pull-ups are necessary. The I2C interface pins on a microcontroller (or on the slave device) are open-collector.

-Adam

On Sun, Apr 15, 2012 at 9:50 AM, Quixotic Nixotic <nixc...@jsdesign.co.uk> wrote:
I am driving a DS3231 I2C clock from a PIC's pins. If the logic state of the pins is always high or low, do I really need pullups on the bus? The only reason I ask is that space is at a premium.

--
You received this message because you are subscribed to the Google Groups "neonixie-l" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/neonixie-l/-/hF9vShAcTecJ.
To post to this group, send an email to neoni...@googlegroups.com.
To unsubscribe from this group, send email to neonixie-l+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/neonixie-l?hl=en-GB.

David Forbes

unread,
Apr 15, 2012, 12:58:59 PM4/15/12
to neoni...@googlegroups.com

Ever taken apart a cell phone recently? Those 0201 resistors are nearly
invisible to the naked eye, they're so small. Two of them won't eat up
much real estate.

--
David Forbes, Tucson AZ

Quixotic Nixotic

unread,
Apr 15, 2012, 1:37:46 PM4/15/12
to neoni...@googlegroups.com
People seem to find my Clock-It website and there's been a lot of interest in my one and two tube clocks. I've got a reasonable set of fades and display modes and I have also got a routine so the cathodes for each tube can be swapped around by the user

People keep asking me if I can supply a kit so I thought it was about time I put something together for other people. So I am working on a small set of modular boards, very much with the home constructor in mind, who tend to not like soldering surface mount parts, so I am trying to avoid their use completely, while designing a compact layout. The DS2321 will be the only surface mount part, which I am going to have space for on the board, but with the option to piggy-back a separate pre-soldered plug-in part which I can supply if people don't feel up to soldering it themselves.

The 18F2520 PIC ports I am using for the I2C bus say they are TTL, so presumably they are not open collector, thus my question whether I need any additional pullups.

David Forbes

unread,
Apr 15, 2012, 1:47:40 PM4/15/12
to neoni...@googlegroups.com
On 4/15/12 10:37 AM, Quixotic Nixotic wrote:
> The
> DS2321 will be the only surface mount part...
>

I know. I was being silly.

> The 18F2520 PIC ports I am using for the I2C bus say they are TTL, so
> presumably they are not open collector, thus my question whether I need
> any additional pullups.
>

The generic ports are TTL, but when they get configured for I2C, they
become open-collector. I2C requires the pull-up resistors to implement
its tricky protocol over two wires.

You'll have to find the room for them. If it helps, 1/8 watt resistors
are a bit smaller than 1/4 watt resistors.

Quixotic Nixotic

unread,
Apr 15, 2012, 3:33:28 PM4/15/12
to neoni...@googlegroups.com

On 15 Apr 2012, at 18:47, David Forbes wrote:

> The generic ports are TTL, but when they get configured for I2C, they become open-collector. I2C requires the pull-up resistors to implement its tricky protocol over two wires.
>
> You'll have to find the room for them. If it helps, 1/8 watt resistors are a bit smaller than 1/4 watt resistors.

I am not using pins that can be configured as an I2C bus per se, but using two ordinary TTL level pins. Is the issue that there is some intermediate state between high and low that will send the whole mess haywire if I don't have a default condition set via resistors?

If only Farnell in the UK sold a resistor with wires that are 1/8w, but I cannot find any.

If Farnell deliver my Raspberry Pi tomorrow as promised I will be a happy bunny. I seem to have been allocated one of the first 700 - Farnell got 700 and RS got 700 last week. That means the Pi Foundation have held back 600 of the initial 2,000 that came to the UK. Presumably these are being sent out to developers who are doing all the educational software development in readiness for the start of the new school year in September.

John S

John Rehwinkel

unread,
Apr 15, 2012, 4:09:36 PM4/15/12
to neoni...@googlegroups.com
>> The generic ports are TTL, but when they get configured for I2C, they become open-collector. I2C requires the pull-up resistors to implement its tricky protocol over two wires.
>>
> I am not using pins that can be configured as an I2C bus per se, but using two ordinary TTL level pins. Is the issue that there is some intermediate state between high and low that will send the whole mess haywire if I don't have a default condition set via resistors?

When you're transmitting information, you can have collisions if you're driving the line high when the receiver tries to
drive it low. This sort of thing is hard on the driver transistors, and leads to weird voltages that aren't valid logic levels.
However, it MAY be possible to avoid such collisions by only transmitting when you're certain the other device won't
try to transmit too. Your device will see the low bits as low, and the high bits as "ouch, you cooked my driver transistor".

The harder to avoid problem comes on receive, when you set your I/O pins to "input". Then your pins aren't pulling
the lines high or low, and the I2C device can only pull them low or let them float. So they float. To random levels. So you'll receive the low bits as low and the high bits as "random". Not terribly useful.

The idea is for the pull-up resistors to make the lines high by default, and then the MCU and target device can pull them
low as needed. If there's a collision with both devices pulling the lines low, no problem, they just go low, and the I2C
protocol allows for this to be detected and dealt with.

- John

David Forbes

unread,
Apr 15, 2012, 4:12:42 PM4/15/12
to neoni...@googlegroups.com

The DS2321 is not a real part, according to Google. The DS1307 is.

It's true that you don't need a pullup on SCL, since it's only ever
driven by the CPU. But the SDA line changes direction between writing
the pot address and reading the data. It will drift to an invalid state
without a pullup, which may cause problems unless you do some clever
software hacks such as ensuring that the SDA input is ignored unless
it's actively being driven by the RTC chip.

Feel free to experiment with I2C with no pullup resistor, but you might
want to use an oscilloscope to show you what happens to the SDA line
when it changes direction.

Both Digikey and Mouser in the USA sell 1/8 watt thru-hole resistors.
Too bad for you.

Grahame Marsh

unread,
Apr 15, 2012, 4:31:07 PM4/15/12
to neoni...@googlegroups.com

> On 4/15/12 12:33 PM, Quixotic Nixotic wrote:
>>
>>
>> If only Farnell in the UK sold a resistor with wires that are 1/8w,
>> but I cannot find any.
>>

I think they do - e.g. Farnell number 1700243 or 9343040 are 125mW 3k3
axial leaded - or are you looking for something else?


G

Cobra007

unread,
Apr 15, 2012, 11:20:39 PM4/15/12
to neonixie-l
Just an idea, if you really don't have space for an extra resistor,
the port B has internal pull-ups that can be enabled and might do the
trick for you. You won't be able to use the I2C peripheral of the PIC
in that situation as it is on port C and cannot be re-located on the
18F2520, but with a bit of bit banging, this is not a problem.

Michel

Jon

unread,
Apr 16, 2012, 12:41:04 AM4/16/12
to neonixie-l

Bit old school I know, but if board _area_ is the issue, you could
mount the resistors vertically... Or (getting more outlandish) you
could mount them horizontally, but have them bridge over and sit on
top of the DS3231 package.

Jon

Quixotic Nixotic

unread,
Apr 16, 2012, 12:43:43 AM4/16/12
to neoni...@googlegroups.com

On 15 Apr 2012, at 21:12, David Forbes wrote:

The DS2321 is not a real part, according to Google. The DS1307 is.

It's true that you don't need a pullup on SCL, since it's only ever driven by the CPU. But the SDA line changes direction between writing the pot address and reading the data. It will drift to an invalid state without a pullup, which may cause problems unless you do some clever software hacks such as ensuring that the SDA input is ignored unless it's actively being driven by the RTC chip.

Feel free to experiment with I2C with no pullup resistor, but you might want to use an oscilloscope to show you what happens to the SDA line when it changes direction.

The part is a DS3231 David. I finally realised that the data line is bidirectional and on a PIC read it will be floating in the breeze so I understand now. I must have been being particularly dense yesterday. I am sure I will find room for some pullups.

Grahame thanks for finding the 125mW resistors at Farnell. Somehow when I choose 125mW in the parametric search it only shows up one wired resistor, an out of stock US part at a crazy price, 1885813.

When doing small PCB designs it always seems the biggest space hog is clearance for the mounting holes.

Thanks to all who helped,

John S

Mich...@aol.com

unread,
Apr 16, 2012, 11:57:24 AM4/16/12
to neoni...@googlegroups.com
Link to the site?
Reply all
Reply to author
Forward
0 new messages