Shop OBEX P1 Docs P2 Docs Learn Events
level shifter voor 3.3 to 5V I2C communications — Parallax Forums

level shifter voor 3.3 to 5V I2C communications

ErikdSErikdS Posts: 37
edited 2012-05-28 22:00 in BASIC Stamp
Can anyone recommend a good level shifter (plus eventually some demo code, would be welcome)?
Thx!
Erik

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-05-28 13:21
    Erik,

    I2C uses pull-up resistors on both the clock and data lines. The chips connected to these lines should only pull the lines low, not set them high.

    I've used a 5V real time clock many times with a Propeller with both lines pulled to 3.3V using 10K resistors. The Prop never sees more than 3.3V and the 3.3V logic is enough for the RTC to read. It would have also been possible to pull the lines to 5V since the current is limited by the 10K resistors, the 5V wouldn't hurt the Prop.

    I had a hard time believing that there would only be 3.3V on the I2C line so I monitored it with an oscilloscope while the Prop and RTC were communicating. Sure enough, the signals never went above 3.3V.

    So basically you shouldn't need a level shifter for 3.3V and 5V I2C devices.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-05-28 15:00
    If you really need to mix 5V and 3.3V devices on an I2C bus, you can use the level shifter shown in this post:

    -Phil
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-05-28 15:52
    Phil,

    I sure hope you'll correct me if I gave Erik any bad information.

    I suppose it's possible for some 3.3V devices not to tolerate a 5V logic signal even if the 5V is through a 10K pull-up resistor, and it's possible for some 5V devices not to recognize 3.3V as a logic high, but I'd think (based on my limited experience) the cases where you had both such components on a single I2C bus would be rare.

    Would a level shifter on an I2C bus that had both 3.3V and 5V devices be needed very often?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-05-28 17:11
    Duane Degn wrote:
    Would a level shifter on an I2C bus that had both 3.3V and 5V devices be needed very often?
    You've identified the two conditions where it might be needed:
    1. Some 5V devices may not recognize 3.3V as a "high".
    2. Some 3.3V devices may either not tolerated 5V, or their protection diodes will pull the pulled-up +5V down to a lower level.

    The only advice I can give is to read the datasheets for the devices be designed in and use a level converter if the devices on the bus are incompatible.

    -Phil
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-05-28 17:23
    Thanks for the clarification Phil.
  • FranklinFranklin Posts: 4,747
    edited 2012-05-28 22:00
Sign In or Register to comment.