SEAShell - my new software for accessing Serial EEPROMs
Some time last year, I got myself a few serial EEPROMs. As the name suggests, they are accessed serially using some serial protocol(usually SPI or I2C). Hence these serial EEPROMs don’t have a parallel data/address bus that we normally associate with EEPROMs in general. Here is a photo of my SPI based EEPROM, a 25AA256 from Microchip.

Memory is written to and read from the EEPROM using a serial protocol, which may be SPI or I2C. I already wrote a post back then when I interfaced a SPI based serial EEPROM with my arduino board. This time, I have interfaced that same SPI based serial EEPROM(the microchip 25AA256 to be precise) with my Dallas DS-5000T microcontroller development board which has a DS5000T in it and that is basically a variant of the classic 8051 core. But alas! the DS-5000T does not support hardware SPI!! Hardware SPI means that you don’t have to implement the SPI protocol in software and by just setting up a few registers you can simply copy the byte in the output register and the microcontroller takes care of encoding each bit within that byte and sending it across the SPI bus. So that means that I had more work to do. I had to in fact implement the SPI bus protocol in software, which is also known by the term bit-banging. But before we discuss further let us look at how an SPI bus looks like:

SPI bus schematic
As you can see, SPI works on a master-slave paradigm. The master is the one which initiates all data transfers. There can be several slaves on the same bus and the master has to select the slave it wants to communicate with by asserting the chip select line(also called slave select or SS line) of that slave. Here, SCLK stands for slave clock. The master has to supply the slave with clock pulses for it to work. MOSI means master out-slave in and MISO means master in-slave out. The former is used to transmit data from the master to the slave and the latter is used to receive data from the slave into the master. SS means slave select as indicated earlier. The slave would be active only when SS is asserted by the master by pulling it low.(It is asserted by pulling it low since SS is active low, indicated by the bar on top).
For more details about SPI, you can take a look at this Wikipedia link. The way my system is designed is that my DS5000T board acts my master which issues the EEPROM read/write commands. And the EEPROM itself acts as a slave. In order to communicate with the DS5000T, I use the PC serial port. The software that runs on my DS5000T, I call SEAShell - or Serial EEPROM Access Shell. It is a shell in the sense that it allows you to read/write a particular byte within the EEPROM. Although I have not created a file system of sorts within my EEPROM, but that is an eventual goal. It would be really cool to have my own seemFS or Serial EEPROM Embedded Micro File-System. (I must add, I continue to impress myself with my cool names
).
So here is how my SEAShell setup looks like:

Schematic setup for SEAShell.
The circuit schematic of the connections between the DS5000T and the serial EEPROM is also very simple for this setup. It is so simple that I am not going to bother creating another drawing for it. The connections between the DS5000T and the 8 pin 25AA256 Serial EEPROM can be done as follows:
a) Pin 2.0 of DS5000T –> Pin 1 of 25AA256 (/CS)
b) Pin 2.1 of DS5000T –> Pin 2 of 25AA256 (SO)
c) Pin 2.2 of DS5000T –> Pin 3 of 25AA256(/WP)
d) Pin 2.3 of DS5000T –> Pin 7 of 25AA256(/HOLD)
e) Pin 2.4 of DS5000T –> Pin 6 of 25AA256(SCK)
f) Pin 2.5 of DS5000T –> Pin 5 of 25AA256(SI)
g) Pin 4 of 25AA256 should be grounded.
h) Pin 8 of 25AA256 should be raised to VCC, +5 volts DC.
For more details about the 25AA256, you may refer to its official datasheet here.
The connection between the PC and the DS5000T board, of course uses the MAX232A level shifter(since RS232 voltage levels are not TTL compatible) and a few 10 uf capacitors. That is a standard connection and a bit of google can tell you how to interface a MAX232 IC with a serial port.
On the software side, I have written two programs for this:
a) SEAShell.asm : An assembly language program for the 8051 that is burned into my DS5000T development board (using my very own gnuProload software, of course!). The job of this program is to provide an interface to the human user through the PC serial port to allow the human user to interactively (or in an automated way), read/write data into the Serial EEPROM. The source code for SEAShell.asm can be found here.
b) SEAShellUtil.c : A C language program that utilizes the automated mode of SEAShell.asm and can be used to read/write big files into the serial EEPROM. This is needed because we cannot expect a human user to type in several thousand bytes in case he/she wants to write them into the EEPROM. The source code for SEAShellUtil.c can be found here.
So my complete SEAShell setup comprises of the following components:
a) The DS5000T development board. Note that any 8051 compatible microcontroller can be used because my SEAShell.asm uses only standard 8051 assembly language, no fancy 8051 variant specific things are used. Here I used my DS5000T because it was convenient for me. I could also have used my Atmel AT89S52 here.
b) The software consisting of SEAShell.asm and SEAShellUtil.c
c) The Serial EEPROM itself, which is a 25AA256. You can use any serial EEPROM which is based upon SPI. But you would have to modify the page size within the SEAShell.asm and SEAShellUtil.c code. Also find out whether the EEPROM accepts data MSB first or LSB first and then modify SEAShell.asm accordingly.
d) A simple serial port communication software like minicom (on Linux) or HyperTerminal(on Windows). Note that, SEAShellUtil.c would run only on Linux. However, you may try out the interactive mode of SEAShell.asm on any OS that has a serial port communication software(like minicom or HyperTerminal).
Here is a photo showing my hardware setup for SEAShell:

Photo showing hardware setup for SEAShell.
The EEPROM can be seen on the right hand side fitted in a small ZIF socket. My DS5000T board can be seen on the left. Still further to the left you can see the serial port DB9 connector which connects to the PC on the other end. Also above the serial port connector is the small USB connector that supplies power to the DS5000T development board directly from my PC.
And to clarify matters more, here is a screencast which shows SEAShell in action:
I hope you like this post about SEAShell. As usual, do write in your comments and suggestions. Your comments go a long way in inspiring me to create more such stuff
!
Until next time, this is Seemanta saying good-bye to you all and take care!
Hello Seemanta,
This is looking great. The ASCII art is real cool.
~Sujai.
@Sujai,
Thanks for your comment. I hope you enjoyed the video too
~seemanta
Seem, nice screencast, awesome ascii art. And yeah, your names *ARE* impressive. The resemblance to your name is uncanny
I wish I understood more about hardware though!