Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Interfacing 5V and 3.3V Logic
Got a question from a customer why I do not carry any level converters. The reason is level converters are rarely needed. While I am on this, why not make it an article here.

What you should know

Many 3.3V circuits are 5V tolerant. That means you can connect 5V output directly to 3.3V input. Check your datasheet.

Many CPUs (like ATMEL AVR used in Arduinos) running at 5V are 3.3V friendly lowering their minimum VIH to less than standard 70% Vcc (thanks ATMEL). If you have 3.3V circuit that is 5V friendly and such CPU with low VIH threshold, you can just connect them directly. Check your datasheets, look for absolute maximum VIH on 3.3V input and input threshold VIH on 5V inputs. Terms may vary, sometimes datasheet just states "5V tolerant".

Most pins have schottky ESD protection diodes. Many datasheets will not show them, but they are there. Back in 80s the CMOS circuits used to be extremely sensitive, many times it would be dead before you inserted it into the socket. Most common circuits today are CMOS and they can take lot of touching thanks to protection diodes. Check ATMEGA328P datasheet, section 13.1 I/O Ports Overview shows this as well - All I/O pins have protection diodes to both VCC and Ground as indicated in Figure 13-1.

Schottky diode has voltage drop approx 0.3-0.4V

So how to interface 3.3V to 5V ?

This is an example of 5V Arduino to 3.3V SD card connection.

[Image: arduino_schematic.jpg]

How does it work?

We do not need to concern ourselves with low level. Logic 0 is zero volt with 3.3V logic and 5V logic. The problem is logic H.

In the example above the 5V logic H will get divided to 5V / (1.8k + 3.3k) * 3.3k = 3.24V on the SD card. So 5V output -> 3.3V input is covered.

How about 3.3V output to 5V input? Lookup I/O Pin Input Threshold Voltage vs. VCC VIH in ATMEGA328P datasheet. In my version it is Figure 29-163 and says that with Vcc=5V anything above 2.7V is considered logic H. So 3.3V -> 5V path covered as well.

Further Simplification

The circuit above may be simplified even further if we know for sure that SD card has protection diodes - the R2, R4, R6 can be dropped. The 5V logic will get clipped by protection diodes.

What if the 5V side has higher VIH ?

Normally in CMOS world the logic H is 70% Vcc, at Vcc=5V this is 5V * 0.7 = 3.5V. That means 3.3V is not high enough to register as H onthe 5V side.

Solution is simple - place pull-ups on the 5V side. In the case of above schematic, the pull-up around 5x higher than interface resistors R1, R3, R5, so something like 10k. Turns out many microcontrollers including ATMEL already have some pull-ups so you can enable them in software. When logic H is output at 3.3V side, the pullup will flow the current toward the output. Because logic H is done by high-side drive, it cannot sink current from 5V pull-up and protection diode will sink it into 3.3V supply boosting the H level on 3.3V side by 0.4V. Add another (5V-3.7V) / (10k + 1.8k) * 1.8k = 198mV on top of that for a nice VIH=3.9V logic high with 0.4V noise immunity from required 3.5V.

There is other solutions and tricks involving external diodes etc. But I like simple, use what we already have in the circuit. Also when you get into higher speeds (100MHz+), protection diodes may not be used anymore due to their switch time and different solutions should be used.
I haven't worked on a project with level shifting yet, but I will keep this in mind.
Thanks for a thorough explanation Roman.
Bob D
Yes Roman thanks for the detailed tip. I am sure I will be connecting an sd card to the arduino in the future.

Forum Jump:

Users browsing this thread: 1 Guest(s)