Go Down

Topic: Wire library enables internal pull-ups -> bad for 3.3V I2C devices. (Read 5819 times) previous topic - next topic

nickgammon

There would be a bit of a danger if a 3.3V I2C device lets the line go high (by going high impedance) the line will only reach 3.3V if you pull-up to 3.3V and not 5V. Thus, although the Atmega running at 5V will read that as a high, it is only just (it registers high at above 2.7V) - page 412 of datasheet. You would need a reasonably powerful (ie. low) pull-up resistor to make sure it reached that level quickly enough.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

jepjep

Hello,

I am a student (but 48 yo!) just beginning to work with Arduinos. I am in this situation, too: a 5 V Arduino to connect to a 3.3 V device through I2C, so I designed a circuit with 3.3 V pull-up resistors.

The "easy" solution to disable internal pull-up, as reported, was to comment out disable Arduino internal pull-ups enable in twi_init().

What I have done is adding a new parameter in Wire.begin() wich allows enabling (default) and disabling pull-up resistors in the way that begin function is back-compatible.
I've had to modify Wire.h, Wire.cpp, utility/twi.h, utility/twi.c:

Example:


#include <Wire.h>
//...
void setup() 
{
 //...
 // new parameter: WIRE_DISABLE_PULLUPS WIRE_ENABLE_PULLUPS

 Wire.begin(WIRE_DISABLE_PULLUPS); //start Wire with pullups disabled

 // Previous library version works as usual:
 // Wire.begin(); //start Wire with pullups enabled (default case)
 // and can be called this way, too:
 // Wire.begin(WIRE_ENABLE_PULLUPS);
//...
// The 'begin' implementation makes Wire.begin(address) works as usual
// but it can be called too as: Wire.begin(address, WIRE_DISABLE_PULLUPS)
// ...
}

Attached you will find Wire library with this new specification/proposal.

Regards,
Josep
 

Go Up