How to program a 93C66 EEPROM chip with an AVR microcontroller?
The 93C66 is a serially (MICROWIRE) Electrically Erasable Programmable ROM (EEPROM) chip with 4 kbit (4096 bit, can be ORGanized as 256 x 16bit or 512 x 8bit) memory space. Here a DIL version (which I will use in my moving message sign project) of the 93C66:

93C66 topview (DIL)
The 93C66 (ST) has five control pins, D (data input), C (clock), S (chip select), ORG (8- or 16bit organized) and Q (data output)
Other pins are Vcc (supply), Vss (GND) and DU (Don't Use) Connect four (S, C, D and Q) of the five control pins directly to an AVR, connect Vcc to +5V, and connect Vss to GND. Tide ORG and DU to GND, the 93C66 will now be 8bit (byte) organized, meaning that the user can store 512 bytes.
If you power the 93C66 up, you must keep the S (chip select) line low, at init the 93C66 is in Write Disable mode (you cannot write yet) Here a diagram on how to connect the 93C66 to an AVR microcontroller:

Diagram of a 93C66 (wired for 8-bit use, thus 512 bytes memory space) connected to an AVR microcontroller
The 93C66 operates with seven Instructions, READ (fetch data), WRITE (store data), EWEN (enable writing), EWDS (disable writing), ERASE (clear byte), ERALL (clear all memory), WRALL (write whole memory with the same data) The instructions are built from a startbit (a single bit), opcode bits (2 bits) and address bits (9 bits) The instructions READ, WRITE and ERASE are 3 bits (addressfield set by you), all other instructions are 12 bits. You can make for example a table with the instructions-data. Here the instruction set from the datasheet:

The first instruction (you must transmit) is the EWEN instruction, this enables writing (without executing this instruction you cannot write (write protected) any data to the 93C66), when the 93C66 is write enabled, you can write your data to it. The transmission works as follow: First make the S (chip enable) line high (clock must be low), then set the right data on the D pin, now give one clock (clock rises, causing the transmission), now the first bit is clocked in the 93C66, this is the startbit. Next shift the other bits in the 93C66, when this is happen the 93C66 is write enabled.
Now you can start writing your data into the 93C66, use the WRITE instruction. When writing you must set an address and use your data (databyte). Start at address 0 (000000000), the addressfield is 9 bits wide and the datafield is 8 bits wide (when ORG pin is grounded) and the instruction code (the WRITE instruction is 3 bits), so a totall of 20 bits (thus 20 clocks needed) Make the software so the instructions are combined with addressfield and datafield
After the write transmission make de S line low, and wait for 'ready' status (poll the Q line, the Q pin (PINx of AVR) must be programmed as 3-state aka hi-Z input) The writing of one byte takes about 10 msec max. , you can verifiy this with i.e. a 2-color LED. When the LED turns red the 93C66 is busy (and writing), when the LED turns green the write process is finished (or use a display, see picture below) In 'busy' state the Q line is low (0), in 'ready' state high (1) When writing a lot of data ofcourse this will take more time, the totall memory can take up to 5.12 seconds maximum, because 512 bytes x 10 msec = 5.12 seconds, but probably a shorter time (about 2 sec) If your program can't wait this long, you must write byte per byte (takes max. 10 msec), if still to much time, use an interrupt which checks the 'ready' state. The maximum clockspeed of the 93C66 is 1 MHz, but you have to take care about the propagation delays (check the values in the datasheet pages 18-21) When your project need to store data now and then, you can better make it Write Diable (with the EWDS instruction) to be sure nothing can happen to your data.
The next step is verifying if your data was written ok in the 93C66. Use the READ instruction. Reading data is a bit more difficult. First transmit the READ instruction, then clock out the data from the Q pin. The READ bits are, startbit + opcode + address bits (12 bits), set the address to read from and make the S pin high, now start the outgoing transmission (rising egde of the clock causes the data to transmit into the D input of the 93C66), at the point the last bit of the 12 ingoing bits is reached, make D low (this data called the dummy bit) and start clocking in your data from the Q pin (data read at the falling egde of the clock now) At the end of the transmission make the S pin low again (end of transmission) Now make the 93C66 Write Disable (with the EWDS instruction) to be sure your data is protected.
I have made the next test circuit on a vero-board, for verifying the stored data.

Test board with on the left the 93C66, in the middle an AT90S1200, and on the left a 74HC595 providing data for two TIL311 displays
[back to top]