4.9.11 Memory Access via SPM/LPM
The ATA8210/15 provides a self-programming mechanism for downloading and uploading program code by the MCU itself. The self-programming can use any available data interface and associated protocol to read code and write (program) that code into the program memory.
All information in this section relating to Flash memory is valid for the ATA8210 only.
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 the store program memory (SPM) command and the buffer can be filled either before the page erase command or between a page erase and a page write operation:
Option 1, fill the buffer before a page erase:
- Fill temporary page buffer
- Perform a page erase
- Perform a page write
Option 2, fill the buffer after page erase:
- Perform a page erase
- Fill temporary page buffer
- Perform a page write
If only a part of the page needs to be changed, the rest of the page must be stored (for example, in the temporary page buffer) before the erase and, then, be rewritten. When using option 1, the bootloader provides an effective read-modify-write feature, which allows the user software to first read the page, do the necessary changes and, then, write back the modified data. If option 2 is used, it is not possible to read the old data while loading because the page is already erased. The temporary page buffer can be accessed in a random sequence. It is essential that the page address used in both the page erase and page write operation is addressing the same page.