Using the EEPROM programmer without the utilities

Every so often I get asked about faultfinding the EEPROM programmer circuit … usually by people who have followed my notes and made their own circuit on breadboard. This is absolutely fine (it’s why I try to blog my projects) but buying a PCB from me might save you some time in the long run … hint hint. 🙂

I originally wrote the articles as a demonstrator on how parallel ROMs and EEPROMs communicate. The command-line and Windows utilities were written almost as an addendum – a convenience thing, later. But communicating directly with the Arduino (without those utilities) is heartily encouraged! If nothing else, you’ll understand what those utilities are doing for you.

In this blog post, I’ll walk you through communicating with the Arduino (after you’ve flashed my sketch to it) to read some data from a ROM, and write to an EEPROM.

Communicating with the Arduino

The Arduino sketch communicates via serial in plain ol’ ASCII: 9600 baud, 8-N-1. Any comms software will do, but the serial monitor that’s built into the Arduino IDE is perfectly fine (which is what I tend to use when developing).

To send commands to the Arduino, enter it into the textbox at the top, and hit return. The Arduino will parse it and send its response, which appears in the area below.

A command is just the first letter of the sentence. Anything else on the line depends on the command. The commands are:

  • R – reads 16 bytes of data from the EEPROM
  • W – writes up to 16 bytes of data to the EEPROM
  • P – set write-protection bit (Atmels only, AFAIK)
  • U – clear write-protection bit (ditto)
  • V – prints the version string

A good first step is to type “V” into the text box in the serial monitor and hit return, and it should respond with the sketch’s version number.

This is the string that gets put into the “Version” box in the Windows app, and was my half-arsed attempt at making the utility software backwards compatible, in case I ever need to update the communication protocol on the Arduino.

If you see this, you know you have written the sketch to the Arduino correctly, and your comms settings are correct.

Reading data from a ROM or EEPROM

The “R” command will read data from the ROM. You provide the address to start (as four hex characters) and it will read sixteen bytes of data from the ROM, and send it to you as hex.

So, if I insert an EEPROM I have knocking-around on my desk, and enter “R0000”:

I’ll get the first sixteen bytes (bytes 0 to 15, inclusive) :

If I enter “R0010”, I’ll get bytes 16 to 31 (remember that the four characters after ‘R’ are the address in hex, and “0010” in hex is “16” in decimal):

And “R0020” will get me bytes 32 to 47 inclusive:

The string of text returned is in this format:

[address of start of data, in hex]:[sixteen bytes of data, in hex],[CRC checksum of data, in hex]

Writing data to an EEPROM

To write data, use the “W” command, followed by four characters of address, then a colon, then up to sixteen bytes worth of hex data, like this:

This will write 0x00 to the first byte of the EEPROM, 0x11 to the second byte, and so on. To see the changes, just enter “R0000” to read back the first sixteen bytes of the EEPROM:


About the Checksum

When the Arduino reads back data, it also provides a single-byte checksum, separated from the data by a comma. The Arduino can also accept a CRC when writing data (separated by a comma in the same manner). This is optional! The utilities implement it as a simple integrity-checker, but I don’t expect you to calculate your CRC by-hand when just experimenting with EEPROM writing. This is supposed to be a tutorial, not a software-engineering exam!

The CRC is simply all the bytes in the data, XOR’d together. So in my first example of reading data, above:

The CRC is 0x2d, because 0x4c XOR 0x93 XOR 0x80 … XOR 0x53 equals 0x2d.

[To the EEPROM Writer Project Page.]