
168
ATmega8515(L)
2512A–AVR–04/02
Figure 73. Addressing the Flash during SPM
(1)
Note: 1. The different variables used in Figure 73 are listed in Table80onpage 174.
Self-Programming the
Flash
The program memory is updated in a page by page fashion. Before programming a
page with the data stored in thetemporary page buffer, the page must beerased.The
temporary page buffer isfilled one word atatimeusing SPM and the buffercan be filled
eitherbeforethe page erase command orbetween a Page Eraseand a Page Write
operation:
Alternative 1,fill the bufferbeforeaPageErase:
• 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.
If only a partof the page needs to be changed, the restof the page must be stored(for
exampleinthetemporary page buffer) beforetheerase, and then be rewritten. When
using alternative 1, the Boot Loaderprovides an effective Read-Modify-Write feature
which allows theusersoftwaretofirst read the page,dothenecessary changes, and
then write back themodifieddata. If alternative 2 is used, it is not possibletoread the
old data while loading sincethe page is already erased.Thetemporary page buffercan
beaccessed in a random sequence. Itis essential that the page address used in both
the Page Eraseand Page Write operation is addressing the same page. See “Simple
Assembly Code Example for a Boot Loader”onpage 171 for an assembly code
example.
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
Commenti su questo manuale