6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Wed Jun 26, 2024 9:07 am

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Mon May 20, 2024 7:53 am 
Offline

Joined: Wed Nov 16, 2011 9:39 am
Posts: 48
I have been glancing at the Winbond NOR-flash SPI devices as a simple means of a future storage/harddrive solution. They are ultra small and can store 16 MB of data. But my system is running at 5V and they are 3.3V devices.

Now, since I am bit-banging SPI using a WDC 65C22S, would it be possible to translate 5V signals to 3.3V (and the opposite for the MISO signal) using resistors or some other means of passive components?

I know resistors introduce some sluggishness in the signal, but I don't really know how much or how to measure/calculate that. I am currently running at 3.6864 MHz and as each write to the 65C22 port will take at least 4 cycles this would be ~1000 ns per change (1000/(3.6864/4)).

EDIT: Perhaps the use of a HCT-device in between MISO on the device and the MISO pin on the 65C22 is enough to handle the input?
EDIT2: The 74HCT125 quad buffer might be a good candidate for MISO, to keep the three-state behavior of the input pin for up to four devices.

/Johan


Top
 Profile  
Reply with quote  
PostPosted: Mon May 20, 2024 1:04 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1436
Location: Scotland
There are many small level shifters designed to connect (e.g.) Arduino to SD memory cards. The protocol at the simple level is SPI. I use one on my Ruby boards - the 'host' is an ATmega and it all runs at 5v. (SPI clock at 8Mhz)

e.g. https://www.sparkfun.com/products/13743

The schematic is there too..

Now, while I have no direct experience of SPI Flash/EEPROM devices, I do have a lot of experience with SPI access to SD cards - and it's not hard, provided you can arrange your data in 512 byte chunks..

Or just get one of these and pull out the pins used for SPI... Or check the schematic, etc.

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Mon May 20, 2024 5:09 pm 
Offline
User avatar

Joined: Fri Dec 12, 2008 10:40 pm
Posts: 1003
Location: Canada
you can make a bi-directional level-shifter with a single MOSFET.

While not an ideal choice I have made 5V<>3.3V shifter with a 2N7000 and two resistors.

Just google "MOSFET level shifter"

_________________
Bill


Top
 Profile  
Reply with quote  
PostPosted: Tue May 21, 2024 4:51 am 
Offline

Joined: Wed Nov 16, 2011 9:39 am
Posts: 48
Thanks for the tips!

I think I have an SD card breakout board lying around that I bought several years ago which I had completely forgotten about. Might try to revive that.

Also I've been meaning to learn more about transistors to better understand the analog side of digital circuitry so maybe building a level shifter with a MOSFET is a good project to start with.


Top
 Profile  
Reply with quote  
PostPosted: Tue May 21, 2024 5:45 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8460
Location: Southern California
We've had a few topics over the years about this.  The nice thing about SPI in this regard is that there are no bidirectional lines.  The fact that every line handles data in one direction only, makes it extra easy to do the voltage translation.  For going from 5V logic to 3.3V, you can use just a pair of resistors, plus a capacitor to cancel the pole created by the resistors and the input capacitance of your SPI flash IC so you're not slowing the edges down.  One thing I've used to go the other direction is a 74LS07 open-collector buffer (unfortunately it doesn't exist in 74HC), and then use a pull-up resistor at its output, typically 4.7K.  You can see both of these in the 65SIB breakout board to use on 65SIB devices, shown on the front page of my site (linked below).  Its data sheet is at http://wilsonminesco.com/65SIBbreakout/ ... -31-22.pdf .  Focus on the top-center of the schematic on page 3.  The schematic includes all the stuffing options.  No breakout board would include all of the stuffing options.  For going from 5V to 3.3V, focus on R1-R2-C6.  For going from 3.3V to 5V, it's U1, the hex open-collector buffer.  The open collector allows wire-OR'ing.  Since, with 65SIB, there will be up to seven devices on the chained interface, I have the pull-up on the master, not each device.  One of the uses of this breakout board is to put plug tiny (like postage-stamp-sized) SPI-10 modules (like your flash) into the 65SIB.  One I have available is shown a little further up the front page of my site.  See the description and pictures there, and the link to the datasheet.

_________________
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?


Top
 Profile  
Reply with quote  
PostPosted: Tue May 21, 2024 9:00 am 
Offline

Joined: Wed Nov 16, 2011 9:39 am
Posts: 48
GARTHWILSON wrote:
We've had a few topics over the years about this.  The nice thing about SPI in this regard is that there are no bidirectional lines.  The fact that every line handles data in one direction only, makes it extra easy to do the voltage translation.  For going from 5V logic to 3.3V, you can use just a pair of resistors, plus a capacitor to cancel the pole created by the resistors and the input capacitance of your SPI flash IC so you're not slowing the edges down.  One thing I've used to go the other direction is a 74LS07 open-collector buffer (unfortunately it doesn't exist in 74HC), and then use a pull-up resistor at its output, typically 4.7K.  You can see both of these in the 65SIB breakout board to use on 65SIB devices, shown on the front page of my site (linked below).  Its data sheet is at http://wilsonminesco.com/65SIBbreakout/ ... -31-22.pdf .  Focus on the top-center of the schematic on page 3.  The schematic includes all the stuffing options.  No breakout board would include all of the stuffing options.  For going from 5V to 3.3V, focus on R1-R2-C6.  For going from 3.3V to 5V, it's U1, the hex open-collector buffer.  The open collector allows wire-OR'ing.  Since, with 65SIB, there will be up to seven devices on the chained interface, I have the pull-up on the master, not each device.  One of the uses of this breakout board is to put plug tiny (like postage-stamp-sized) SPI-10 modules (like your flash) into the 65SIB.  One I have available is shown a little further up the front page of my site.  See the description and pictures there, and the link to the datasheet.


Thanks Garth for the detailed explanation. The circuit for the 65C22 outputs looks a bit similar to what I had in mind. I have to admit I don't understand the need for the capacitor and the concept of poles and when I googled it I quickly got lost in math equations. I am clearly lacking some fundamental understanding of analog circuit design in this regard. I also realize that my suggestion of using something like 74HCT125 would require additional combinatorial logic to OR the MISO signal.


Top
 Profile  
Reply with quote  
PostPosted: Tue May 21, 2024 9:28 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8460
Location: Southern California
The resistance, multiplied by the input capacitance of your SPI flash IC plus the capacitance of traces, connectors, etc., results in a time constant, the time to charge up the input to 1-(1/e)*the terminal voltage, which in this case is 3.3V (assuming you use a CMOS 65c22 which can pull pretty much all the way up to 5V with a light load).  1-(1/e) is about 63%, and that much of 3.3V is a little under 2.1V.  Without the capacitor in there, you'll have at least a couple dozen extra nanoseconds in the time constant of the rise and fall time, with the resistors I show; but it'll be longer if you increase the resistors' values.  If you're bit-banging, that probably won't be enough slowing to cause any trouble; but it's so easy to get rid of it, so why not.  Just getting in the habit will probably prevent problems in other things in the future.  I have working sample 65c22 SPI bit-bang code at http://wilsonminesco.com/6502primer/SPI.ASM, in the 6502 primer.

Oh, I just found a post you'll want to see:  viewtopic.php?p=92374#p92374 .  The third paragraph there also has a link to forum member akohlbecker's online circuit simulation, with description of how to operate it.

_________________
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?


Top
 Profile  
Reply with quote  
PostPosted: Wed May 22, 2024 8:42 am 
Offline

Joined: Wed Nov 16, 2011 9:39 am
Posts: 48
Thanks for a clear explanation. Like you say speed is probably not an issue in this context but might as well adopt a good habit when I am at it. I will consider this going forward. Thanks for the link as well, I guess that post covered mostly what I was asking about (it's a bit tricky to find the right threads in this well of information).

OT: Right now I am stuck with getting my simple 23LCV1024 SPI SRAM to work. I got it working on breadboard several years ago so it's probably a small stupid bug somewhere in the current code. :oops:


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 41 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: