22
8008H–AVR–04/11
ATtiny48/88
To write an EEPROM memory location follow the procedure below:
Poll the EEPROM Program Enable bit (EEPE) in EEPROM Control Register (EECR) to make
sure no other EEPROM operations are in process. If set, wait to clear.
Set mode of programming by writing EEPROM Programming Mode bits (EEPM0 and
EEPM1) in EEPROM Control Register (EECR). Alternatively, data can be written in one
operation or the write procedure can be split up in erase, only, and write, only.
Write target address to EEPROM Address Registers (EEARH/EEARL).
Write target data to EEPROM Data Register (EEDR).
Enable write by setting EEPROM Master Program Enable (EEMPE) in EEPROM Control
Register (EECR). Within four clock cycles, start the write operation by setting the EEPROM
Program Enable bit (EEPE) in the EEPROM Control Register (EECR). During the write
operation, the CPU is halted for two clock cycles before executing the next instruction.
The EEPE bit remains set until the write operation has completed. While the device is busy with
programming, it is not possible to do any other EEPROM operations.
5.3.5
Preventing EEPROM Corruption
During periods of low V
CC, the EEPROM data can be corrupted because the supply voltage is
too low for the CPU and the EEPROM to operate properly. These issues are the same as for
board level systems using EEPROM, and the same design solutions should be applied.
At low supply voltages data in EEPROM can be corrupted in two ways:
The supply voltage is too low to maintain proper operation of an otherwise legitimate
EEPROM program sequence.
The supply voltage is too low for the CPU and instructions may be executed incorrectly.
EEPROM data corruption is avoided by keeping the device in reset during periods of insufficient
power supply voltage. This is easily done by enabling the internal Brown-Out Detector (BOD). If
BOD detection levels are not sufficient for the design, an external reset circuit for low V
CC can be
used.
Provided that supply voltage is sufficient, an EEPROM write operation will be completed even
when a reset occurs.