Joined: Fri Aug 30, 2002 1:09 am Posts: 8546 Location: Southern California
|
Note: for the final spec, go to the 29th post.
Elsewhere, I recommended standardizing on a pinout for tiny I²C modules. I called it I2C-6. Daryl used it on at least one of his SBCs that he sells. Below is a recommendation for a similar type for SPI, equally hobbyist-friendly, using standard pin headers of .025" square posts with pin spacing at .100". These fit into standard perfboard for wire-wrapping or soldering.
Background
I²C and SPI are synchronous-serial interfaces that are very popular because they dramatically reduce the number of required connections compared to parallel. (There are other very similar, lesser-used ones too, like SMBus and Microwire.) Besides the fact that they make computer construction easier, once you have an I²C and/or SPI interface in place, a 6502 with only a 64KB memory map can access lots of ICs on the serial buses, and even megabytes (or gigabytes) of flash memory, without complex address decoding or banking. Many of the ICs have only 8 pins. Putting D/A and A/D converters, keyboard scanners, display drivers, temperature sensors, signal generators, general-purpose I/O bits, relay drivers, real-time clocks, etc. on separate boards or modules becomes much, much easier.
I²C and SPI do not have the timing requirements that an asynchronous serial interface like RS-232 does. They are easy for the hobbyist to bit-bang with any standard I/O IC like the 6522 VIA, 6520 PIA, 6526 CIA, or non-65-family parts with similar functions. Daryl also sells his 65SPI chip which does the SPI shifting in hardware, has 8 slave-select outputs, and has a 6502-compatible bus interface. SPI needs a minimum of four signal lines (clock, data in each direction, and select) compared to I²C's two (a bidirectional data line, plus a clock line which is also potentially bidirectional), but SPI can go about a hundred times as fast because it doesn't rely on passive pull-up resistors like I²C does. All SPI lines are unidirectional, making it easy to do voltage translation if needed (like from 5V to 3.3V). There's a summary of several serial interface methods here. Thousands of ICs are available with I²C and SPI.
My own first application for SPI-10 is 4MB flash memories that come in a wide SO-8 package about 0.2"x0.3". Here's one of my home-made modules, and to the right, a standard SD card and a CompactFlash card. On the SPI-10 module, pin 1 is marked by a white stripe (I used white-out), and the two-pin 90° header is to put a jumper on for write-protect. 40% of the board is just there as a handle to unplug it, and/or to have a small space to label what you have stored on the module. You can make your own file system, or even use the module without any file system at all.
Attachment:
flashModuleCompare.jpg [ 46.06 KiB | Viewed 10020 times ]
I've used this flash memory before, but only on an SO-to-DIP adapter, plugged into an 8-pin DIP socket. The SPI-10 module makes it much more convenient to insert and remove, and it won't get damaged in handling like a DIP's pins would.
The details
Here's a view looking down on a straight (vertical) 10-pin SPI-10 header. The pin header goes on the controller (master), while the module (slave) gets the socket, since the modules might be too vulnerable to mechanical damage if they had the pins. Pin 8 is cut as a keyway, and the corresponding hole in the module's socket is blocked to prevent inserting the module backwards or offset. Mark pin 1 in the PCB's silkscreened legend, or with white-out or a permanent marker if by hand.
Attachment:
SPI-10pinout.jpg [ 34.85 KiB | Viewed 10020 times ]
If you want a little more protection for the pins on the controller board, there's no reason you couldn't use a shrouded pin header like this one:
Attachment:
shrouded10.jpg [ 4.13 KiB | Viewed 10020 times ]
The picture is from a distributor's site and does not have pin 8 cut off. If it's too hard to reach into the shroud with a wire cutter, you might be able to pull the pin out from the back with needle-nose pliers.
Position 8 of the module's socket is blocked, to prevent plugging it in wrong. On this one, I pulled the contact out before soldering the socket to the tiny board, and jammed a piece of wire with yellow insulation in the hole. Note the white-out marking pin 1.
Attachment:
moduleSocket.jpg [ 24.17 KiB | Viewed 10020 times ]
You could put the pin header at the edge of the board as well, using 90° pins. You can flip it if desired. Here's the pinout:
Code: Gnd MOSI MISO (cut) IRQ\ ┌────┬────┬────┬────┬────┐ │ 2 │ 4 │ 6 │ (8)│ 10 │ ├────┼────┼────┼────┼────┤ │ 1 │ 3 │ 5 │ 7 │ 9 │ ═════╧════╧════╧════╧════╧════╧══════(board edge) Vdd Clk CS\ AUX RST\
Pin and signal descriptions:
- VDD. Voltage should be labeled, especially for a 5V controller port, or a lower-voltage (mostly meaning 3.3V) module. A port that is only for flash memory probably will not be 5V since AFAIK there are no SPI flash memories available in 5V.
- Ground
- Clk. SPI serial clock input to module. SPI can go as fast or slow as you like. At the high end, some devices can go up to about 200MHz. At the low end, you can even stop the clock at any time with no ill effects, even in the middle of a byte, for example to service an interrupt (although the ISR should not affect the SPI).
- MOSI. Master-out, slave-in serial data.
- CS\. Active-low chip select input to module.
- MISO. Master-in, slave-out serial data. SPI can run data in both directions at once, although most devices don't have any reason to.
- AUX. Some SPI ICs or devices have a separate pin for register select, for example a small graphics LCD I have which sees a "1" there to mean incoming bits are data and a "0" to mean they're an instruction. Use this like any way you like; but I expect that the few times it's needed, it will be an input to the slave.
- Empty. Pin 8 is cut off, and the hole in the socket is plugged, to prevent accidentally plugging the module in backwards or offset.
- RST\. Active-low reset input to the module. Most SPI ICs won't need this.
- IRQ\. Interrupt-request open-collector/open-drain output from the module. The module can pull this line down to request service. Use a pull-up resistor to VDD on the controller.
If you absolutely must to have a smaller module, note that the six essential connections are all together, in pins 1 through 6, so positions 7 through 10 could be left off and the module's socket could be hardly over .300" wide.
If you want it hot-pluggable, the controller should be able to turn off the power and bring its outputs low. I recommend using an LED next to the pin header on the controller board to show when the port is powered up (modern, high-efficiency LEDs only need a mA or two, not 20!), and if there's any risk of damage, you should plug in or unplug a module only when the light is off. The restriction could be eliminated with special connectors to make sure the power and ground get connected before the other lines (when plugging in) and disconnected last (when unplugging); however, a goal here is to use common, inexpensive parts that are widely available to hobbyists and can be inserted into common perfboard.
My first interest in this is for SPI flash memories. I'm starting with a board that accommodates the 25VF032 and 26VF064 4MB and 8MB flash memories and others with the same footprint (and I plan to make the board available to everyone); but SPI-10 can also serve to connect circuits centered on tons of other SPI ICs, as mentioned in the 2nd paragraph from the top.
SPI-10 does not in any way nullify 65SIB. 65SIB is a bus for multiple slaves, with auto addressing and other things that SPI-10 does not have. SPI-10 is for single-address modules that will usually be quite small.
If you see any problems, or anything needs clarification, please let me know, and I'll edit this so all the corrections will be incorporated into the head post (after discussion if necessary). Each builder can of course do things however (s)he wants; but I hope this proposed standard will not only be helpful in individuals' projects but will facilitate the sharing of projects.
_________________ 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?
|
|