Datasheet
23
ATtiny828 [DATASHEET]
8371A–AVR–08/12
Note: See “Code Examples” on page 7.
5.4 Register Description
5.4.1 EEARL – EEPROM Address Register Low
z Bits 7:0 – EEAR[7:0]: EEPROM Address
The EEPROM address register is required by the read and write operations to indicate the memory location that is being
accessed.
EEPROM data bytes are addressed linearly over the entire memory range (0...[256-1]). The initial value of these bits is
undefined and a legitimate value must therefore be written to the register before EEPROM is accessed.
Devices with 256 bytes of EEPROM, or less, do not require a high address registers (EEARH). In such devices the high
address register is therefore left out but, for compatibility issues, the remaining register is still referred to as the low byte
of the EEPROM address register (EEARL).
Devices that to do not fill an entire address byte, i.e. devices with an EEPROM size not equal to 256, implement read-
only bits in the unused locations. Unused bits are located in the most significant end of the address register and they
always read zero.
C Code Example
unsigned char EEPROM_read(unsigned int ucAddress)
{
/* Wait for completion of previous write */
while(EECR & (1<<EEPE))
;
/* Set up address register */
EEAR = ucAddress;
/* Start eeprom read by writing EERE */
EECR |= (1<<EERE);
/* Return data from data register */
return EEDR;
}
Bit 76543210
0x21 (0x41) EEAR7 EEAR6 EEAR5 EEAR4 EEAR3 EEAR2 EEAR1 EEAR0 EEARL
Read/Write R/WR/WR/WR/WR/WR/WR/WR/W
Initial Value X X X X X X X X