I know there are similar questions on the site, but I wanted to ask it from a somewhat different perspective.
- I've got a 5V device (Device A) that can operate at 3.3V.
- I've got a 3.3V device (Device B) that does not have 5V tolerant inputs.
- I want to connect these two devices together to communicate over an SPI interface.
- I want to be able to operate Device A selectively at 5V or 3.3V.
- Device B is independently powered and always runs at 3.3V.
I know I can use (and have successfully used) a buffer (e.g. 74HCT125) powered by the same voltage as Device A to boost Device B's signals up to 5V. I'm not as sure of the best approach for the other direction though (i.e. dropping Device A's outputs to an appropriate level for Device B).
I've read the Sparkfun Tutorial on the subject. <-- 2022: The Sparfun tutorial link is dead.
It quite possibly reffered to this retired tutorial -
Using the logic level converter
Maybe see also the following Sparkfun guides:
Bi-Directional Logic Level Converter Hookup Guide
TXB0104 Level Shifter Hookup Guide a learn.sparkfun.com tutorial
Level Shifter - 8 Channel (TXS0108E) Hookup Guide
Single Supply Logic Level Converter Hookup Guide
Bi-Directional Logic Level Converter Hookup Guide {another one}
They offer a few ways to approach the "downward" level shifting. What is the preferred way of handling this aspect? Since I'm using SPI here, the classic MOSFET solution for I2C seems like overkill to me since I don't need bidirectionality. I like the Inline Resistor approach for its simplicity, but I am uncertain how to size the resistor. The CLK and MOSI pins of Device B are specified with V_IH_min = 0.7 * V_cc = 2.31V, V_IH_max = V_cc + 0.3 = 3.6V and with Input leakage current of max 0.5 uA.
By my math this means I need to drop between 1.4V and 2.6V in the case (1) where Device A is operating at 5V and no more than 1V in the case (2) where Device A is operating at 3.3V. If I assume the 0.5 uA leakage current is responsible for the voltage drop then case (1) calls for a resistor between a 1.4/0.5e-6 = 2.8 MegOhm and a 2.6 / 0.5e-6 = 5.2 MegOhm resistor(!). And case (2) calls for a resistor no smaller than 2 MegOhm. Therefore case (2) is dominated by case (1), and I should pick a resistor somewhere in between the calculated range, like 3.3 MegOhm for example.
That value seems ginormous to me (especially when the SF tutorial is showing values like 10 kOhm) ... and that is just for the max input leakage current (no min or typical is specified) is there a flaw in my reasoning or calculations, or is this not the preferred way to interface the devices (e.g. the Diode method)?
If it matters, one case of Device B I'm thinking of is a 23K256 SRAM, but I'm trying to account for a variety of devices.