Not posted in a while, have I? It’s not because I haven’t been tinkering – actually, it’s the reverse. I’ve had so many projects on, but I’ve not been able to spend a serious amount of time documenting them. Which is a poor habit to get into, I admit. I should be documenting before I start on the next one.
Anyway, here’s one that’s been half-written-up for a while, that’s nice and self-contained. I hope it’s useful to someone.
There’s been a number of occasions recently where I’ve needed to program a parallel EEPROM. I’ve been experimenting with BBC micros, and building my own DIY-6502 single-board computer.
I like EEPROMs, certainly compared to EPROMs. There’s no blanking-under-UV process, no special programming voltage required … I always feel like EEPROMs behave how you’d expect a programmable, read-only memory component to behave.
Programming a parallel EEPROM is nice and logical and straightforward, and can be done with very few components. If I had the space to setup my RiscPC I might have been tempted to program it via its parallel printer port … but I don’t really have the space, and I’d ideally like the programmer to be small, that I can leave in a box when I don’t need it. So: I need a small, not particularly powerful computer, but with a good amount of digital I/O pins. An Arduino it is, then!
My initial design for a programmer involved an Arduino Nano and some 74xx595s for the address lines … in fact, when I discovered this site later on, I was pleasantly surprised to see someone else’s design use exactly the same approach. However, when I started looking at the small extra cost of an Arduino Mega (with all its many digital I/O pins) I realised that I could make just as simple a programmer (with NO extra components) in a much shorter time.
For a while I would just put a EEPROM programmer together with a Mega, a breadboard and a lot of jumper wires whenever I needed it, but that got annoying really quickly! And there was always the worry that one of the many wires could be loose, and the EEPROM programmed incorrectly.
So I’ve built a tiny PCB for the job. It just sits on top of the IO pins on the far end of the Mega, and routes those pins to a ZIF socket. I’ve also added red and green LEDs so I get visual feedback when it is reading or writing.
The circuit is just an iteration on my post about reading parallel ROMs … but now it writes, too.
Speed isn’t particularly an issue when programming parallel EEPROMs, so I didn’t feel any real need to control the digital pins at the port level (an optimisation which would allow us to control eight bits in one go, rather than each bit at a time). Instead, I chose to make the PCB design as simple as possible (so I could etch it with my CNC) and then deal with the complexity in software.
Here’s my PCB design. As you can see, it’s incredibly simple.
I’ve provided the PCB layout in case you have the ability to etch your own PCBs. I used my CNC to isolation-route the design. But to be honest, the circuit is so simple that you could do it with stripboard if that’s all you have.
It’s worth noting that I’ve chosen to put the tracks on the upper (component) side of the board rather than the lower (solder) side. This is because the pins that I have soldered onto the board to connect it to the Mega have those little bits of plastic on them … so they’re practically impossible to solder from underneath. Whereas the turned-pin DIL socket (which holds the ZIF socket) is slightly raised off the board, and is therefore easier to solder.
Software on the Arduino
The Arduino is programmed to listen on the serial port and accept commands. I’ve kept the protocol brief, but ASCII-based (so I can test it with a serial comms package). It reads ROMs in blocks of sixteen bytes, and sends them down the serial port as ASCII hex. And it accepts blocks of up to sixteen bytes to write, in the same format. There’s a primitive CRC check, just to verify that no corruption occurs along the serial link.
It’s available for download here. Just copy and paste it into a sketch in the Arduino editor: Arduino_Code
If you want to quickly see it working, compile the code onto your Arduino, then enter “R0000″ in the serial monitor and hit return. You should see the first 16 bytes sent to you in hex, with a checksum.
Software on the PC
So now we need a utility that’ll control the Arduino in a slightly friendlier manner. I put off writing a utility for ages – instead resorting to turning a ROM image into a C array, and then embedding that in my Arduino project. But that’s rubbish. Putting-off writing a reasonable toolset is just making your life difficult for yourself.
And then, when I finally got around to it … it turns out that accessing the serial port under Windows is really not that difficult!
Here is a command-line executable for Windows. Run it without any parameters if you want to see the command-syntax: eeprommer_v3 (527KB)
Note that this version should now work on Windows XP machines, thanks to compiling it against an older toolset and providing the C runtime DLL in the zip file with it. The DLL probably isn’t necessary for versions of Windows later than XP.
It takes around 5ms to latch a byte when writing. And when you’ve added-in the serial-comms, verifying the data, etc, writing a 32K EEPROM takes about 5-10 minutes. This is OK for what I need, but will get irritating if I need a quicker iteration time.
The solution is page write, which is a facility that many EEPROMs provide that lets you write about 64 bytes in about the same amount of time as it currently takes to write just one byte! I might have a go at implementing that one day – a 64x writing increase sounds like a good win!