30
ATmega64A [DATASHEET]
8160D–AVR–02/2013
8.6.5
EEDR – EEPROM Data Register
Bits 7:0 – EEDR7.0: EEPROM Data
For the EEPROM write operation, the EEDR Register contains the data to be written to the EEPROM in the
address given by the EEAR Register. For the EEPROM read operation, the EEDR contains the data read out from
the EEPROM at the address given by EEAR.
8.6.6
EECR – EEPROM Control Register
Bits 7:4 – Res: Reserved Bits
These bits are reserved bits in the ATmega64A and will always read as zero.
Bit 3 – EERIE: EEPROM Ready Interrupt Enable
Writing EERIE to one enables the EEPROM Ready Interrupt if the I-bit in SREG is set. Writing EERIE to zero dis-
ables the interrupt. The EEPROM Ready Interrupt generates a constant interrupt when EEWE is cleared.
Bit 2 – EEMWE: EEPROM Master Write Enable
The EEMWE bit determines whether setting EEWE to one causes the EEPROM to be written. When EEMWE is
written to one, writing EEWE to one within four clock cycles will write data to the EEPROM at the selected address.
If EEMWE is zero, writing EEWE to one will have no effect. When EEMWE has been written to one by software,
hardware clears the bit to zero after four clock cycles. See the description of the EEWE bit for an EEPROM write
procedure.
Bit 1 – EEWE: EEPROM Write Enable
The EEPROM Write Enable Signal EEWE is the write strobe to the EEPROM. When address and data are cor-
rectly set up, the EEWE bit must be set to write the value into the EEPROM. The EEMWE bit must be set when the
logical one is written to EEWE, otherwise no EEPROM write takes place. The following procedure should be fol-
lowed when writing the EEPROM (the order of steps 3 and 4 is not essential):
1.
Wait until EEWE becomes zero.
2.
Wait until SPMEN in SPMCSR becomes zero.
3.
Write new EEPROM address to EEAR (optional).
4.
Write new EEPROM data to EEDR (optional).
5.
Write a logical one to the EEMWE bit while writing a zero to EEWE in EECR.
6.
Within four clock cycles after setting EEMWE, write a logical one to EEWE.
The EEPROM can not be programmed during a CPU write to the Flash memory. The software must check that the
Flash programming is completed before initiating a new EEPROM write. Step 2 is only relevant if the software con-
tains a Boot Loader allowing the CPU to program the Flash. If the Flash is never being updated by the CPU, step 2
Boot programming.
Caution: An interrupt between step 5 and step 6 will make the write cycle fail, since the EEPROM Master Write
Enable will time-out. If an interrupt routine accessing the EEPROM is interrupting another EEPROM access, the
Bit
7654
3210
MSB
LSB
EEDR
Read/Write
R/W
Initial Value
0000
Bit
7
6
5
4
321
0
–
EERIE
EEMWE
EEWE
EERE
EECR
Read/Write
R
R/W
Initial Value
0
X
0