443
8331B–AVR–03/12
Atmel AVR XMEGA AU
2.
Load the NVM CMD register with the read fuses command.
3.
Set the CMDEX bit in the NVM CTRLA register. This requires the timed CCP sequence
during self-programming.
The result will be available in the NVM DATA0 register. The CPU is halted during the complete
execution of the command.
33.11.4
EEPROM Programming
The EEPROM can be read and written from application code in any part of the flash. Its is both
byte and page accessible. This means that either one byte or one page can be written to the
EEPROM at once. One byte is read from the EEPROM during a read.
33.11.4.1
Addressing the EEPROM
The EEPROM can be accessed through the NVM controller (I/O mapped), similar to accessing
the flash program memory, or it can be memory mapped into the data memory space to be
accessed similar to SRAM.
When accessing the EEPROM through the NVM controller, the NVM address (ADDR) register is
used to address the EEPROM, while the NVM data (DATA) register is used to store or load
EEPROM data.
For EEPROM page programming, the ADDR register can be treated as having two sections.
The least-significant bits address the bytes within a page, while the most-significant bits address
the page within the EEPROM. This is shown in
. The byte address in
the page (E2BYTE) is held by the bits [BYTEMSB:0] in the ADDR register. The remaining bits
[PAGEMSB:1] in the ADDR register hold the EEPROM page address (E2PAGE).
Together E2BYTE and E2PAGE hold an absolute address to a byte in the EEPROM. The size of
E2WORD and E2PAGE will depend on the page and flash size in the device. Refer to the device
datasheet for details on this.
Figure 33-2.
I/O mapped EEPROM addressing.
E2PAGE
E2BYTE
BIT
NVM ADDR
0
B
S
M
E
T
Y
B
B
S
M
E
G
A
P
DATA BYTE
PAGE
PAGE
EEPROM MEMORY
BYTE ADDRESS
WITHIN A PAGE
PAGE ADDRESS
WITHIN THE EEPROM
E2BYTE
00
01
02
E2PAGEEND
E2PAGE
00
01
02
E2END