6.112.1 Description
SPM can be used to erase a page in the program memory, to write a
page in the program memory (that is already erased), and to set Boot Loader Lock bits. In
some devices, the Program memory can be written one word at a time. In other devices, an
entire page can be programmed simultaneously after first filling a temporary page buffer.
In all cases, the program memory must be erased one page at a time. When erasing the
program memory, the RAMPZ and Z-register are used as page address. When writing the program
memory, the RAMPZ and Z-register are used as page or word address, and the R1:R0 register
pair is used as data(1). The Flash is word-accessed for code
space write operations, so the least significant bit of the RAMPZ register concatenated
with the Z register should be set to ‘0
’. When setting the Boot Loader
Lock bits, the R1:R0 register pair is used as data. Refer to the device documentation for
the detailed description of SPM usage. This instruction can address the entire program
memory.
The SPM instruction is not available on all devices. Refer to Appendix A.
Operation: | |||
(i) |
PS(RAMPZ:Z) ← 0xffff |
Erase program memory page | |
(ii) |
PS(RAMPZ:Z) ← R1:R0 |
Write program memory word | |
(iii) |
PS(RAMPZ:Z) ← R1:R0 |
Load page buffer | |
(iv) |
PS(RAMPZ:Z) ← BUFFER |
Write page buffer to program memory | |
(v) |
BLBITS ← R1:R0 |
Set Boot Loader Lock bits | |
Syntax: |
Operands: |
Program Counter: | |
(i)-(v) |
SPM |
None |
PC ← PC + 1 |
16-bit Opcode:
1001 | 0101 | 1110 | 1000 |