EEVblog Electronics Community Forum
Electronics => Beginners => Topic started by: frasdoge on August 06, 2021, 07:28:17 am
-
Hi, I'm designing a board with an ATMega32U4 micro and using it to communicate over I2C/TWI to 3V3 devices. I'm supplying the ATMega32U4 with a 5V supply.
In the datasheet features section it says all IO feature CMOS outputs and LVTTL inputs. In the DC characteristics section for Input High it has minimum 0.2Vcc+0.9 = 1.9 V, which is consistent with LVTTL.
However, in the TWI section it has Input High as 0.7Vcc = 3.5 V. I assume this overrides what those previous 2 sections say.
My question is: how do I connect up TWI for my devices then? I'm not sure whether I'm misreading the datasheet or if I'll need a buffer. Attached is the relevant part of my schematic.
-
0.3VCC and 0.7VCC are levels prescribed by the Philips spec. If the numbers were buried somewhere in the middle of the TWI chapter I would think twice, but if they are given in a dedicated table in "electrical characterisistcs" then it doesn't look like a mistake. The existence of some 50ns "spike filter" further suggests that TWI may use a separate input digitizer, independent from the normal I/O path.
https://www.nxp.com/docs/en/user-guide/UM10204.pdf (https://www.nxp.com/docs/en/user-guide/UM10204.pdf)
-
What you should be looking for is the classic Philips I2C MOSFET Level Shifter circuit. Adafruit have a copy of the original Philips AN97055 (https://cdn-shop.adafruit.com/datasheets/an97055.pdf). NXP's AN10441 (https://www.nxp.com/docs/en/application-note/AN10441.pdf) is the same circuit but they've added some pretty colors and gutted the application note of nearly all the detailed design information that Philips originally provided! |O
For optimum results at high speeds, locate it really close to the 5V ATmega so you can minimize the bus capacitance on the 5V side and use higher value pullups, saving available pulldown current to let you use lower value pullups on the 3.3V side to cope with the unavoidably more spread out bus with its correspondingly higher bus capacitance*. The time constants of the pullup with its own side's bus capacitance on either side of the level shifter should approximately match.
* If you had more 5V devices than 3.3V ones, the optimum level shifter location would be as close as possible to the 3.3V device(s).
-
Thanks everyone, appreciate it!
-
Don't overlook the option of running the AVR at 3.3V, and also check if the I2C inputs of the target devices have ESD diodes (pin abs max voltage Vdd+0.3 or so); if they are 5V tolerant (abs max >6V) you can just run the pullups from +5, no problem.
Tim