Datasheet

Figure 30-3 Addressing the Flash During SPM
(1)
PROGRAM MEMORY
0115
Z - REGISTER
BIT
0
ZPAGEMSB
WORD ADDRESS
WITHIN A PAGE
PAGE ADDRESS
WITHIN THE FLASH
ZPCMSB
INSTRUCTION WORD
PAGE
PCWORD[PAGEMSB:0]:
00
01
02
PAGEEND
PAGE
PCWORDPCPAGE
PCMSB
PAGEMSB
PROGRAM
COUNTER
Note: 
1. The different variables used in the figure are listed in Table 30-7 Read-While-Write Limit,
ATmega64A(1) on page 379.
2. PCPAGE and PCWORD are listed in table Number of Words in a Page and number of Pages in the
Flash in the Signal Names section.
30.8. Self-Programming the Flash
The program memory is updated in a page by page fashion. Before programming a page with the data
stored in the temporary page buffer, the page must be erased. The temporary page buffer is filled one
word at a time using SPM and the buffer can be filled either before the Page Erase command or between
a Page Erase and a Page Write operation:
Alternative 1, fill the buffer before a Page Erase:
Fill temporary page buffer
Perform a Page Erase
Perform a Page Write
Alternative 2, fill the buffer after Page Erase:
Perform a Page Erase
Fill temporary page buffer
Perform a Page Write
Atmel ATmega64A [DATASHEET]
Atmel-8160E-ATmega64A_Datasheet_Complete-09/2015
372