How to write a file to EEPROM?

I don’t know of any good tutorials for doing this, but the hex file format that AVR studio uses is described here. It’s fairly dense.

A good place to start would be erasing your AVR, then downloading the blank eeprom contents to a text file, and start from there. It should look something like this:

The ‘:’ signifies the start of a line, while Pairs of ASCII characters represent hex values.

The first hex byte of a line represents the number of data bytes to follow in that line, usually 0x10 (16 bytes) for AVRs, but not necessarily!

The next two bytes represent the memory address to write the first byte of data on this line to.

The next byte represents what type of line this is (there are six types, but right now all you need to worry about is 0x00 means data and 0x01 means end of the hex file).

The next N bytes (where N is the value of the first byte in the line, usually 0x10, or 16) are the data to be written at sequential addresses, starting at the address given earlier in the line. “Erasing” these bytes sets them to 0xFF.

Finally the last byte is a simple checksum, such that if you add the byte values of all the bytes in the line (everything after the ‘:’) rounding off to a single byte you will get 0. I use an Excel (or Open Office if you prefer) spreadsheet to calculate checksums quickly, which you can download here. Note that it will only work for 16-data byte lines.

The last line is a simple file terminator, and should read “:00000001FF”.

As for how you store your data, it’s up to you, but if you plan on using the AVR-libc EEPROM functions you should read up on them, or use them to write some test values to the EEPROM you can look at. I remember it confused me for a while that integers were written little-endian (least-significant-byte first).

Anyway, I hope that gets you started. What kind of program are you writing that you want to be able to configure?

-Adam