I need to interface my 128a1 to and lcd i2c module that uses 5v logic.
When doing serial interfacing one can often get away with an appropriate resistor in the 5v to 3.3v line and this works ok if the 5v device will 'see' 3.3v logic on the other line.
can this same technique be applied to i2c ?
Happy new year
logic levels with i2c
Re: logic levels with i2c
Probably not. The problem is that both SDA and SCL are bidirectional so you need a solution that will convert 3.3V to 5V *and* convert 5V to 3.3V. The solution to the problem is simplified somewhat by the fact that both SDA and SCL are intended to be driven low actively but pulled high by an external pullup resistor. Philips has an application note on the topic with a MOSFET level conversion circuit:FFMan wrote:can this same technique be applied to i2c ?
http://ics.nxp.com/support/documents/in ... n97055.pdf
SparkFun sells a level converter board that should work:
http://www.sparkfun.com/products/8745
- Don Kinzer
those little boards look good, though note that only 2 of the 4 lines are suitable for i2c according to the posts on the site. They do however open the possibility of creating peripherals that are both suitable for 3.3v and 5v at the flick of a switch which would help me share devices between my zx24 based prototype and 128a1 based final hardware. do you think the board would work if the conversion was 5v to 5v ?
However, a friend of mine uses a propellor and has acheived i2c 3.3v to 5v connection by putting the 4.7k pull high resistors to 3.3v side, and then just putting 1k resistors in series on each of sda and scl lines.
Is this ok ? does it rely upon clamping diodes to protect the cpu, and if so, do these exist on the 128a1 ?
thanks
However, a friend of mine uses a propellor and has acheived i2c 3.3v to 5v connection by putting the 4.7k pull high resistors to 3.3v side, and then just putting 1k resistors in series on each of sda and scl lines.
Is this ok ? does it rely upon clamping diodes to protect the cpu, and if so, do these exist on the 128a1 ?
thanks
It does rely on the protection diodes which the xmega devices (all AVR devices, I think) have. As long as you choose the resistor to limit the current in the protection diodes it should be OK. I've not been able to find a hard specification on the maximum protection diode current. My assumption has been that they can handle at least 1mA (probably 10-20mA). A 1K series resistor would limit the current to (5V - 3.3V - 0.5V)/1K=1.2mA. (The 0.5V figure represents the forward voltage of the diode.)FFMan wrote:Is this ok ? does it rely upon clamping diodes to protect the cpu, and if so, do these exist on the 128a1?
- Don Kinzer
I suspect not. Section 2.3.1 of the application note describes how the circuit works. The third case involves forward biasing the substrate-drain diode which is realized by the difference in the supply voltages. With 5V on both sides, the diode could never conduct.FFMan wrote:do you think the board would work if the conversion was 5v to 5v ?
- Don Kinzer