
8
0943E–AVR–08/08
AVR910
EEPROM Data
Memory Access
Using the “Read EEPROM Data Memory” command, EEPROM contents can be read one byte
at a time. The command sends a memory address ($aa bb) to select a byte location in the
EEPROM.
EEPROM is written one byte at a time, with the “Write EEPROM Memory” command. This com-
mand selects the byte to write just like “Read EEPROM Memory”, and transfers the data to be
written in the last byte sent to the target. For some devices there is no method to detect when
the write cycle has ended. The programmer should simply wait N ms before attempting to send
another command to the interface (the delay N will depend on target device, and can be found in
the programming section of the datasheet). For increased programming speed, polling can be
used as described in the “Flash Program Memory Access” section. An example of an EEPROM
Write is shown in Table 10.
Lock Bits Access
To protect memory contents from being accidentally overwritten, or from unauthorized reading,
the Lock bits can be set to protect the memory contents. As shown on Table 11, the memories
can be either protected from further writing, or you may completely disable both reading and
writing of memories on the chip.
In some devices the Lock bits can not be read, and setting Lock bits can not be verified by the
programmer. To check that the Lock bits have been set properly in these devices, one should
attempt to alter a location in EEPROM. When Lock bit 1 is set, memory locations are not altered.
When both Lock bits 1 and 2 are set, no location can be read, and the result returned will be the
Low byte of the address passed in the command. Setting only Lock bit 2 will have no protective
effect. Before the chip is protected from reading, it has to be successfully protected from writing.
Table 8. Example, Writing “add r17,r18” as $0F12 to Flash Memory Location $10C (Byte Pro-
gramming Mode)
Action
MOSI, Sent to
Target AVR
MISO, Returned from
Target AVR
Write $12 at address $10C, low byte
$60 01 0C 12
$zz 60 01 0C
Wait N ms
Write $0F at address $10C, high byte
$68 01 0C 0F
$xx 68 01 0C
Wait N ms
Table 9. Example, Reading $ab From EEPROM Location $3F
Action
MOSI, Sent to
Target AVR
MISO, Returned from
Target AVR
Read $ab at address $3F
$A0 00 3F xx
$zz A0 00 AB
Table 10. Example, Writing $0F to EEPROM Location $11
Action
MOSI, Sent to
Target AVR
MISO, Returned from
Target AVR
Write $0F at address $11
$C0 00 11 0F
$zz C0 00 11
Wait N ms