I want to connect an nrf24l01/E01-ML01DP5 which is not 5v logic tolerant to the atmega328p using SPI.
Which chip should I use to translate SPI signals from 3.3v to 5v?
txs0108e vs txb0108?
Any other suggestions? and would this interfere with the ability to burn a bootloader while the chip is connected?
An alternative would be to use diodes and pullup resistors. The diode would be in series, with the cathode connected to the Arduino. Then on the anode side, you would have something like a 4.7K - 10K pullup resistor to 3.3V. So the Arduino's MOSI for example can bring the line low, but the diode blocks it from taking the line to 5V. In theory the diodes should be schottky, but regular 1N4148 would probably work too. As jim-p says, this would be for MOSI, CS and SCK. MISO is coming back the other way, and you just connect it directly (3.3V will be read as high by the Arduino).
I AM designing my PCBs.
Connecting MISO directly to MCU is a little iffy since 3.3v is just about the threshold for atmega to read as high. May cause errors. I want all signals 0-5v on the atmega side and 0-3.3v on nrf side.
I would just point out that Adafruit's microSD card module connects MISO directly from the SD card to the Arduino, with no level shifting, and I've never heard of anyone having a problem with it.
Edit: Also, that TI chip is bidirectional, and I see lots of reports of issues with it. And you don't need the lines to be bidirectional like I2C. Each line goes in one direction only. I think you would be better off with the direct MISO connection, and running the other three through a 74xx125, or whatever Adafruit uses in theirs.
If I use 74HC125 I would need two of them. One with vcc tied to 3.3v for SCK MOSI CE and CS, and one with vcc tied to 5v for MISO.
I am looking for a single IC option.
While it does NOT have to be bi directional, we are essentially doing bi-directional translation ...
MOSI and others from 5-3.3 and MISO 3.3-5
Yeah, but if I have other slaves on the bus that would present a problem, as miso will be getting 5v from the other slave devices. How to get around that? I cannot use a diode since it would drop the miso voltage to even less than the 3.3v. The arduino will never see high.
I basically need:
●SCK, MOSI, CS, and CE translated from 5v to 3.3v
●MISO translated from 3.3v to 5v
●Prevent 5v MISO signals from other devices on the SPI bus from overvolting the nrf MISO when they are communicating.
●Not to interfere with any other SPI devices on the bus.
●To be able to burn bootloaders or code to the 328p with icsp
Either a discreet solution (resistors,diodes?) or ic (txb0108,74LV125?) Would be appreciated.
TXS0108E or txb0108
5v=a
3.3v=b
atmega = MOSI MISO CS CE SCK to A side
NRF = MISO MISO CS CE SCK to B side
CS to OE through an inverter (not gate) 74HC1G04 ?
Push pull and tristate. when cs is not active all spi pins are floating as to not interfere with icsp and other slave devices?
Will the above approach work?
I am surprised that I did not find a straightforward approach for complete SPI level shifting
3.3v<->5.0v while having other 5v SPI devices on the bus?
Most methods that I found leave MISO directly connected to the Arduino which exposes the MISO pin from the 3.3v device to overvolting from other SPI signals AND risk the 3.3v MISO signal not registering properly since it is only 3.3v. AND they interfer with uploading or other SPI communication.
The SN74LV1T125 is a single gate translating buffer with active-low ENable. It would translate the 3.3V MISO to 5V, with /CS connected to the /OE pin.
But I don't know about the firmware programming issue.
Edit: And the 74LVC3G34 would handle the other three SPI lines coming out of the 328P. It doesn't have an EN, but doesn't need one on those lines.
So you would need some 74LV chip with EN, powered by 5V to translate the MISO lines from 3.3V to 5V, and another powered by 3.3V to translate the other three lines down to 3.3V. 5V slaves would just bypass both chips.
But I still think you are wrong about 3.3V not being interpreted as high in a 5V system. There are millions of SD cards connected to Arduinos that way, and there just isn't a problem.
You are correct. What I meant was that if I want to protect MISO pin on 3.3v device from other 5v SPI MISO signals I would need to use a diode. In that case, the diode would drop the voltage even further leading to interpretation issues coming from the 3.3v device.
Well, no, not for the MISO line. That would work for MOSI, SCK and CS going the other direction, but MISO needs output enable, controlled by CS, so the slave can transmit only when it is selected. So you would need a SN74LV1T125 for each 3.3V slave.
Run the ATmega at 3.3V and you don't need level shifters. If you are designing the circuit, it is an absolute waste of your time to work with mismatched logic levels.
5V logic is rapidly becoming a thing of the past, so wish it good riddance and move on.