Hey everyone! This topic has come up a lot, I searched the internet and forum and did not find what I was looking for.
Let's start here, the SPI-10 interface:
viewtopic.php?t=4264
I want to take 5V signals (CS/SCK/MOSI) down to 3V3. I'll worry about the MISO line later.
I found this:
https://hackaday.com/2016/12/05/taking- ... -shifters/
And honestly I think the "two resistors" idea is fine. And perhaps it is. But I'm wondering what you think.
What I am REALLY looking for is a DIP-8 IC that turns 3x 5V lines into 3x 3V3 lines. That would be perfect. I have seen the 74HC4050 and that seems to be exactly what I want, but in DIP-8 package (i.e. less lines, smaller package, still DIP). Any ideas on how to find that?
Also, maybe this is just stupid of me, but why don't I just use a 74LS04? Send in 5V, output is 3.3V, double not gates, out comes what I want. Am I missing something there?
What do you use for level shifting SPI?
Any insight is welcome, just looking for ideas. Thanks everyone!
Chad
5V -> 3V3 Level Shifter for SPI-10
Re: 5V -> 3V3 Level Shifter for SPI-10
I haven't needed to do this level shifting myself yet, but the technique I've always had in mind for unidirectional shifting was to use a 74HC245 or similar transceiver to buffer up to eight (or four if you get the 74HC243) 5V=>3.3V signals, with its VCC at 3.3V so it doesn't output more than that to the 3.3V end. You still need current-limiting resistors from the 5V end, but it has internal diodes that are specified to be fine for this purpose, so you only need the one resistor per input.
For the other way I might use 74HCT245 which has TTL-level inputs so should be fine being triggered by 3.3V even with VCC at 5V, being careful to ensue the direction pin is hard-wired the right way around. To me this is a very simple way to achieve it without using specialist parts.
Edit: I guess there's also the LVC range, e.g. 74LVC245, which are 5V-tolerant and don't require current-limiting resistors.
For the other way I might use 74HCT245 which has TTL-level inputs so should be fine being triggered by 3.3V even with VCC at 5V, being careful to ensue the direction pin is hard-wired the right way around. To me this is a very simple way to achieve it without using specialist parts.
Edit: I guess there's also the LVC range, e.g. 74LVC245, which are 5V-tolerant and don't require current-limiting resistors.
- akohlbecker
- Posts: 282
- Joined: 24 Jul 2021
- Contact:
Re: 5V -> 3V3 Level Shifter for SPI-10
I didn't realize the 74LVC245 was available in DIP, I thought that the family had only SMD parts. Nice find!
Last edited by akohlbecker on Thu May 12, 2022 2:03 pm, edited 1 time in total.
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: 5V -> 3V3 Level Shifter for SPI-10
Adding to George's good post:
Jeff alerted us to this series of short videos about TI voltage-translation parts. The circuit potpourri page of the 6502 primer mentions the 74LS07 open-collector buffer which I've used on a few projects for voltage translation. (Unfortunately the 74xx07 is not available in CMOS.) I guess I really should add more about voltage translation in that page.
For a unidirectional line with a CMOS load, going from 5V to 3.3V is easily done with a pair of resistors; but to avoid slowing down the signal's edges due to the resistance and the load capacitance CL which is across R2, there should be a capacitor across R1:
The resistor values don't have to be these exact ones, the ratio of the two values should be kept the same. Standard 5% values go in the sequence 1 - 1.1 - 1.2 - 1.3 - 1.5 - 1.6 - 1.8 - 2 - 2.2 - 2.4 - 2.7 - 3 - 3.3 - 3.6 - 3.9 - 4.3 - 4.7 - 5.1 - 5.6 - 6.2 - 6.8 - 7.5 - 8.2 - 9.1 - 1 (and you can move the decimal place left one place or to the right up to about seven places). The value of the capacitor should be approximately CL*3.3V/(5V-3.3V), or nearly double the CL. Fortunately that doesn't need to be exact, because it may be difficult to predict the exact capacitive load of input(s), sockets, and board traces combined. Forum member akohlbecker posted a simulation of the effect of resistance and capacitance. Click on the L or H at the left end to change the input state, and on the switch in series with the 47pF capacitor to connect and disconnect the capacitor. You can see that without the capacitor connected, the rise and fall times are slow, but the when you connect the capacitor again, you get the square wave back. You'll probably have have more than the 3pF total load that he shows, so your edges will be slower. If you click the L or H at the left end quickly, you'll get kind of a triangle wave out, and if you do it quickly enough, you'll see it hardly reaches valid '1' and '0' states before turning around and heading for the other state. Re-connect the 47pF, and you'll get a nice square wave. Capacitor values don't generally come in the fine-grained sequence given above, and depending on where you buy yours, the next one down from 47pF might be 22pF. I would not go above 47pF.
This matter of capacitance is something the hackaday article missed.
Going the other direction, from 3.3V to 5V, any 74_CT__ gate, powered by 5V, will work, for example 74HCT__ or 74ACT__, since they'll take any input above 2V as a valid logic '1', and their logic '1' output will be very close to 5V.
Jeff alerted us to this series of short videos about TI voltage-translation parts. The circuit potpourri page of the 6502 primer mentions the 74LS07 open-collector buffer which I've used on a few projects for voltage translation. (Unfortunately the 74xx07 is not available in CMOS.) I guess I really should add more about voltage translation in that page.
For a unidirectional line with a CMOS load, going from 5V to 3.3V is easily done with a pair of resistors; but to avoid slowing down the signal's edges due to the resistance and the load capacitance CL which is across R2, there should be a capacitor across R1:
The resistor values don't have to be these exact ones, the ratio of the two values should be kept the same. Standard 5% values go in the sequence 1 - 1.1 - 1.2 - 1.3 - 1.5 - 1.6 - 1.8 - 2 - 2.2 - 2.4 - 2.7 - 3 - 3.3 - 3.6 - 3.9 - 4.3 - 4.7 - 5.1 - 5.6 - 6.2 - 6.8 - 7.5 - 8.2 - 9.1 - 1 (and you can move the decimal place left one place or to the right up to about seven places). The value of the capacitor should be approximately CL*3.3V/(5V-3.3V), or nearly double the CL. Fortunately that doesn't need to be exact, because it may be difficult to predict the exact capacitive load of input(s), sockets, and board traces combined. Forum member akohlbecker posted a simulation of the effect of resistance and capacitance. Click on the L or H at the left end to change the input state, and on the switch in series with the 47pF capacitor to connect and disconnect the capacitor. You can see that without the capacitor connected, the rise and fall times are slow, but the when you connect the capacitor again, you get the square wave back. You'll probably have have more than the 3pF total load that he shows, so your edges will be slower. If you click the L or H at the left end quickly, you'll get kind of a triangle wave out, and if you do it quickly enough, you'll see it hardly reaches valid '1' and '0' states before turning around and heading for the other state. Re-connect the 47pF, and you'll get a nice square wave. Capacitor values don't generally come in the fine-grained sequence given above, and depending on where you buy yours, the next one down from 47pF might be 22pF. I would not go above 47pF.
This matter of capacitance is something the hackaday article missed.
Going the other direction, from 3.3V to 5V, any 74_CT__ gate, powered by 5V, will work, for example 74HCT__ or 74ACT__, since they'll take any input above 2V as a valid logic '1', and their logic '1' output will be very close to 5V.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: 5V -> 3V3 Level Shifter for SPI-10
First, thanks George. I looked more into that 74LVC' ICs and I think I like them! I found Mouser has a thousand 74LVC244's right now in DIP form. So, power them with 3.3V right?
That simulation REALLY hit home. Wow. And just like you said, a triangle wave if you oscillate fast enough! Makes me think of making a triangle wave circuit now 
Overall, good info there, thank you Garth.
So I've been thinking about going in reverse with MISO for a while, and I have 1/2 of an LM393 left over from other stuff. Attached is what I *think* would work for MISO (mine is on PA6 in particular here). The 8.2K and 4.3K tied to 3V3 making a 'low' level of 1.1 V. So then comparing to 1.1V we get either high or low. Because the comparator could oscillate if left untied, I put a big 100K pull-up resistor on it, so leaving the comparator as high-Z. And then finally the 10K pull-up resistor brings it to 5V. Now, this MISO is tied to other 5V components, but... I think this should work? Thoughts? It's almost my first time trying this analog stuff out on my own. I'm open to all criticism!
Thank you again everyone!
Chad
GARTHWILSON wrote:
For a unidirectional line with a CMOS load, going from 5V to 3.3V is easily done with a pair of resistors; but to avoid slowing down the signal's edges due to the resistance and the load capacitance CL which is across R2, there should be a capacitor across R1:
Forum member akohlbecker posted a simulation of the effect of resistance and capacitance.
This matter of capacitance is something the hackaday article missed.
Going the other direction, from 3.3V to 5V, any 74_CT__ gate, powered by 5V, will work, for example 74HCT__ or 74ACT__, since they'll take anything above 2V as a valid logic '1', and their logic '1' output will be very close to 5V.
Forum member akohlbecker posted a simulation of the effect of resistance and capacitance.
This matter of capacitance is something the hackaday article missed.
Going the other direction, from 3.3V to 5V, any 74_CT__ gate, powered by 5V, will work, for example 74HCT__ or 74ACT__, since they'll take anything above 2V as a valid logic '1', and their logic '1' output will be very close to 5V.
Overall, good info there, thank you Garth.
So I've been thinking about going in reverse with MISO for a while, and I have 1/2 of an LM393 left over from other stuff. Attached is what I *think* would work for MISO (mine is on PA6 in particular here). The 8.2K and 4.3K tied to 3V3 making a 'low' level of 1.1 V. So then comparing to 1.1V we get either high or low. Because the comparator could oscillate if left untied, I put a big 100K pull-up resistor on it, so leaving the comparator as high-Z. And then finally the 10K pull-up resistor brings it to 5V. Now, this MISO is tied to other 5V components, but... I think this should work? Thoughts? It's almost my first time trying this analog stuff out on my own. I'm open to all criticism!
Thank you again everyone!
Chad
- Attachments
-
- 3V3to5V.png (10.29 KiB) Viewed 2330 times
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: 5V -> 3V3 Level Shifter for SPI-10
That'll work. I give some tips on making the 339 or 393 work as fast as they can, at viewtopic.php?p=7612#p7612 .
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: 5V -> 3V3 Level Shifter for SPI-10
If your speed requirements are not too ambitious you can just use a simple 2N7000 MOSFET and one or two resistors.
This is a high to low translator: This is a low to high translator: And here is a bi-directional:
The following are waveforms @ 55Khz using 3.6K pull-ups. You can see they would work quite well up to about 500KHz. I have been able to do 1MHz using 470 ohm pull-ups, but I don't have any waveforms to show you. I did these measurements with 3V for low side. They will actually work a bit better with 3.3V
High level source: And corresponding low level output:
Low level source: And corresponding high level output:
This is a high to low translator: This is a low to high translator: And here is a bi-directional:
The following are waveforms @ 55Khz using 3.6K pull-ups. You can see they would work quite well up to about 500KHz. I have been able to do 1MHz using 470 ohm pull-ups, but I don't have any waveforms to show you. I did these measurements with 3V for low side. They will actually work a bit better with 3.3V
High level source: And corresponding low level output:
Low level source: And corresponding high level output:
Bill
Re: 5V -> 3V3 Level Shifter for SPI-10
GARTHWILSON wrote:
Unfortunately the 74xx07 is not available in CMOS.
BTW this is a good example of why I'm a fan of Digikey's product search. 74C906 is not a part you'd discover by searching for 74*07. That's why I prefer to search based on functionality (not a preconceived part#). Go to...
- Product Index ->
Integrated Circuits (ICs) ->
Logic - Buffers, Drivers, Receivers, Transceivers
-- Jeff
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
https://laughtonelectronics.com/Arcana/ ... mmary.html
- CountChocula
- Posts: 101
- Joined: 07 Nov 2021
- Location: Toronto, Canada
Re: 5V -> 3V3 Level Shifter for SPI-10
BillO wrote:
If your speed requirements are not too ambitious you can just use a simple 2N7000 MOSFET and one or two resistors.
Re: 5V -> 3V3 Level Shifter for SPI-10
It is good to see all the different ways y'all tackle this problem. I like a lot of these ideas and will be considering them all going forward. In the least, I hope that this topic can be easily searched on the forum as well for later use.
Thank you all!
Chad
Thank you all!
Chad
-
DerTrueForce
- Posts: 483
- Joined: 04 Jun 2016
- Location: Australia
Re: 5V -> 3V3 Level Shifter for SPI-10
There are a few modules going around online that are basically four of the bi-directional transistor circuits that BillO mentioned, all on one board, approximately the size of a wide DIP12. I know you can get them from places like Adafruit and Sparkfun, but I found a pack of 10 for a fraction of the price on AliExpress. They seem to work so far, though I haven't carried out much in the way of testing yet.
Re: 5V -> 3V3 Level Shifter for SPI-10
If it's just for an SD card then there are some excellent pre-made modules from Adafruit and Sparkfun - I use them on my Ruby boards - far easier than fiddling with shifters and using your own sockets, etc.
e.g.
Sparkfun:
https://shop.pimoroni.com/products/spar ... 7290596423
Adafruit:
https://shop.pimoroni.com/products/adaf ... =370780217
On my Ruby 816 board:
https://unicorn.drogon.net/IMG_20200625_212146_DRO.jpg
-Gordon
e.g.
Sparkfun:
https://shop.pimoroni.com/products/spar ... 7290596423
Adafruit:
https://shop.pimoroni.com/products/adaf ... =370780217
On my Ruby 816 board:
https://unicorn.drogon.net/IMG_20200625_212146_DRO.jpg
-Gordon
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/