Retrochallenge: SD Card hardware

The “disk drive” for the P:65 computer is built out of an Arduino, an SD card breakout board from Sparkfun, and a level converter from Adafruit. It’s great when all these parts cooperate!

July 11? I think it’s safe to say I’m a little behind schedule here. I spent the weekend of the 4th at CONvergence in the Twin Cities, which was a lot of fun but kept me from working on this project. Since getting back I’ve been plugging away at both the hardware and the software. Right now I’m going to briefly talk about hardware.

I’ve already described how I’m going to be using an Arduino as my “disk controller” to read and write files on an SD card. The Arduino is talking to my 6502 computer over a parallel port which uses digital pins 0 through 9 (8 data lines, plus 2 handshaking lines). Now, how do we talk to the SD card?

In some of my other projects, I’ve used the Arduino Ethernet Shield, which contains both an Ethernet port and an SD card slot, both of which are controlled using an SPI protocol. Unfortunately, the shield isn’t going to work for this project because I won’t have enough digital pins. SPI on the Arduino uses pins 11, 12, and 13. That leaves one pin, but the Ethernet shield uses two pins for the Chip Select signals of its two devices. Now, maybe I could use one of the analog pins as part of the parallel port, but… to heck with it! I’ve got something more fun to try!

Instead of using a shield with the built-in SD card socket, I decided to roll my own. Sparkfun sells a nice little SD card breakout board that you can mount on a breadboard. The only trick is that SD cards expect 3.3V power and logic signals, and the Arduino (and the P:65 computer) run at 5V.

Conveniently, I already had a solution for that problem. A couple months ago, I picked up a couple nifty level converter breakout boards from Adafruit. I never got around to using them, but the principal is simple enough: connect all the 5V signals on one side, the 3.3V on the other, and Presto! The Arduino even has a 3.3V supply, so I didn’t even have to build a voltage divider!

Getting the signals hooked up to the SD card took a little research and a little trial and error. SD cards support several communications protocols in addition to SPI, and as a result the signal names on the breakout board aren’t the familiar MOSI, MISO, and CLOCK. The comments in the product page had a few slightly different suggestions for the circuit. For the record, here’s what worked for me:

With this setup, I was able to do a few quick tests using the Arduino SD card library, and everything worked as expected. Well, after I spent half an hour trying to figure out what was wrong before remembering to hook up VCC…

There’s still a lot of software to write, but we’ll get into that later. I hope to have at least one function completely working pretty soon!