436
8331B–AVR–03/12
Atmel AVR XMEGA AU
out the program memory code. It has the capability to write into the entire flash, including the
boot loader section. The boot loader can thus modify itself, and it can also erase itself from the
flash if the feature is not needed anymore.
33.11.1.1
Application and Boot Loader Sections
The application and boot loader sections in the flash are different when it comes to self-
programming.
– When erasing or writing a page located inside the application section, the boot
loader section can be read during the operation, and thus the CPU can run and
execute code from the boot loader section
– When erasing or writing a page located inside the boot loader section, the CPU is
halted during the entire operation, and code cannot execute
The user signature row section has the same properties as the boot loader section.
33.11.1.2
Addressing the Flash
The Z-pointer is used to hold the flash memory address for read and write access. For more
details on the Z-pointer, refer to
”The X-, Y-, and Z- Registers” on page 11
.
Since the flash is word accessed and organized in pages, the Z-pointer can be treated as having
two sections. The least-significant bits address the words within a page, while the most-signifi-
cant bits address the page within the flash. This is shown in
. The word
address in the page (FWORD) is held by the bits [WORDMSB:1] in the Z-pointer. The remaining
bits [PAGEMSB:1] in the Z-pointer hold the flash page address (FPAGE). Together
FWORD and FPAGE holds an absolute address to a word in the flash.
For flash read operations (ELPM and LPM), one byte is read at a time. For this, the least-signifi-
cant bit (bit 0) in the Z-pointer is used to select the low byte or high byte in the word address. If
this bit is 0, the low byte is read, and if this bit is 1 the high byte is read.
The size of FWORD and FPAGE will depend on the page and flash size in the device. Refer to
each device’s datasheet for details.
Once a programming operation is initiated, the address is latched and the Z-pointer can be
updated and used for other operations.
Table 33-1.
Summary of self-programming functionality.
Section being Addressed during
Programming
Section that can be Read
during Programming
CPU Halted?
Application section
Boot loader section
No
Boot loader section
None
Yes
User signature row section
None
Yes