Pages: [1]   Go Down
Author Topic: TURNING OFF PULL UPS WHEN USING I2C  (Read 1748 times)
0 Members and 1 Guest are viewing this topic.
Texas, land of the free, home of the stupid
Offline Offline
Sr. Member
****
Karma: 5
Posts: 268
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm not sure if this is the correct area for this issue, but it is the most applicable that I 've found.

History:  I have some 3.3V I2C peripherals which are not 5V tollerant.  I2C friendly,Bidirectional Level Translators would seem to be the common solution.  I have a real hard time hand soldering mini SMD's and do not like reflow.  Plus, "Keep It Simple Stupid" works really well for me....
Mike Cook (Grumpy Mike) posted a response to another thread in the general electronics section which indicated that: 1) if you could 'HACK' thw Wire library to turn off internal pull ups ( on A04 & A05), and 2) (i think that this is what he meant) connected the Analog Ref in to 3.3V, and 3) ran your pull ups to 3.3V bus, you could do I2C with these types of devices without the need of level translators (again, this is what I think he was getting at.  Have'nt been able to get him to respond to the thread to confirm or deny).

My Objective:  If my assumptions are correct, why can'nt someone add a function to (NOT the Wire lib, but to:) twi.c in /libraries/Wire/utility/... to turn off the pull ups used by I2C?
"twi_init(void)" in twi.c (arduino 0022, I haven't had a chance to check 1.0 yet) sets the port bits to enable the pull ups, based upon the type of controller.  Is there a simple way to add parameter checking to stop this process, or, a function to reverse it?  Or is there a way to do it in the user's (my) code?

I'm old and senile, but I aint stupid (though many others have disputed that issue), but I don't have enough smarts to put this one together....

Thanks for any help and consideration.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 545
Posts: 27353
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

"2) (i think that this is what he meant) connected the Analog Ref in to 3.3V,"

That part would not necessarily be needed. Your part is not putting out an analog signal that needs measuring is it?

I agree with the rest - need a software guy to do that, or figure out how to add  "if define # no_pullup" or something.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Texas, land of the free, home of the stupid
Offline Offline
Sr. Member
****
Karma: 5
Posts: 268
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Crossroads,
Yes sir, Bi-directional comms between the periph and the Arduino.  In the thread which was referenced, I think it was you who mentioned TXBxxx devices, but they don't seem to work too well with I2C (0108's in particular).  A TI support engineer suggested a PCA9306 and is sending me two samples, but those little bugs are really small....

So, you think that, electrically, it should work?  Given that, what do you think about putting inline asm code in, after the wire.begin, to reset the port bits and turn the pull ups off that way??

Thanks for the response and getting me in the right board.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 545
Posts: 27353
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

"Given that, what do you think about putting inline asm code in, after the wire.begin, to reset the port bits and turn the pull ups off that way??"

Could work. I don't know if the library will keep turning them on. Need more software knowledge than I have.

Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 634
Posts: 34529
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The problem with doing that is that they will have spent some time being on. You are better just removing the lines that turns them on in the libary. It is very easy to find.
If you can't do that then use a libary that dosn't enable them by default like the "I2C Master" libary.
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 98
Posts: 4813
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Could you run it on a stand-alone MCU at 3.3V?

Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Texas, land of the free, home of the stupid
Offline Offline
Sr. Member
****
Karma: 5
Posts: 268
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Grumpy_Mike,
Oops, yea, that sounds logical and dangerous... Rats,, but thanks for saving the lives of a couple of breakout boards.  I've found the code that turns the pull ups on in twi.c (under /libraries/Wire/utilities/).  Not famiiar with library I2C_Master.  Google, here I come.  I knew you were the guy to ask.  Many thanks.

Smoke,
in production, yes,,maybe, but, in development, no.  I need easy access to the serial monitor for debugging.  Good idea though.  Thanks.

Crossroads, yea, sounded good to me to.  Oh, well, I guess that I'll just rip the Wire & utility libs.....

Thanks Guys.  Good one to ya'.
Logged

Offline Offline
Edison Member
*
Karma: 19
Posts: 1041
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

1) Look in twi.c

2) Find digitalWrite

3) Comment it out


It might be a better idea to copy the Wire library to something like Wire_Nopullup before doing it, so you can do both (and then rename the .h and .cpp files to Wire_Nopullup also)
Logged

Texas, land of the free, home of the stupid
Offline Offline
Sr. Member
****
Karma: 5
Posts: 268
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Wiz,
I think a better idea is to change the SET BIT instructions in the twi.c initialization to CLEAR BITs.

I would probablly have to do the same if I use I2C Master lib (to change the default settings from enable pullup to disable pullups).
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Wiz,
I think a better idea is to change the SET BIT instructions in the twi.c initialization to CLEAR BITs.

I would probablly have to do the same if I use I2C Master lib (to change the default settings from enable pullup to disable pullups).

just one word of advice, the Arduino MEGA 2560 has 10kOHM pull-up resistors to the SDA and SDL pins that cannot be disabled by software!
So if we are writing an I2C bus that will suport arduino megas (and 3,3V devices) we should take that in account
Logged

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 159
Posts: 2916
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Is this really necessary to worry about? If you have 2.7K pullups to 3.3V on the
peripheral board, and the 5V chip pullups are enabled then, due to voltage-divider
action, you'll only get a voltage increase at the pins of

(5v-3.3V) * 2.7K/(2.7K+40K) = 0.1V      <-- 328 chip
(5v-3.3V) * 2.7K/(2.7K+10K) = 0.36V    <-- 2560 chip

exclusive of the clamping effect of the internal diodes in the 3.3V chip. IOW,
3.4V or 3.66V. I doubt that would damage anything. The clamping diodes are
barely even engaged. Also, you have the 40K/10K pullups limiting the current
flow into the clamping diodes. So, ????

The other thing is, just for general safety issues, I always use small value
series-Rs [220-330 ohms] in the I/O lines, in any case.
Logged

Pages: [1]   Go Up
Jump to: