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). When setting the Boot Loader Lock bits, the R1:R0 register pair is used as data. Refer to the device documentation for detailed description of SPM usage. This instruction can address the entire Program memory.

The SPM instruction is not available in all devices. Refer to the device specific instruction set summary.

Note: 1. R1 determines the instruction high byte, and R0 determines the instruction low byte.

Operation:

 

(i)

(RAMPZ:Z) ← $ffff

Erase Program memory page

(ii)

(RAMPZ:Z) ← R1:R0

Write Program memory word

(iii)

(RAMPZ:Z) ← R1:R0

Write temporary page buffer

(iv)

(RAMPZ:Z) ← TEMP

Write temporary page buffer to Program memory

(v)

BLBITS ← R1:R0

Set Boot Loader Lock bits

 

Syntax:

Operands:

Program Counter:

(i)-(v)

SPM

Z+

PC ← PC + 1

16-bit Opcode:

1001 0101 1110 1000