Datasheet
221
ATtiny828 [DATASHEET]
8371A–AVR–08/12
Although the least significant bit of the Z-register (Z0) should be zero for SPM, it should be noted that the LPM instruction
addresses the Flash byte-by-byte and uses Z0 as a byte select bit.
The only SPM operation that does not use the Z-pointer is setting the boot loader lock bits. The content of the Z-pointer is
ignored and will have no effect on this operation.
Once a programming operation is initiated, the address is latched and the Z-pointer can be used for other operations.
21.8.2 Page Erase
To execute Page Erase:
z Set up the address in the Z-pointer
z Write “00000011” to SPMCSR
z Execute an SPM instruction within four clock cycles after writing SPMCSR
The data in R1 and R0 is ignored. The page address must be written to PCPAGE in the Z-register. Other bits in the Z-
pointer are ignored during this operation.
If an interrupt occurs during the timed sequence above the four cycle access cannot be guaranteed. In order to ensure
atomic operation interrupts should be disabled before writing to SPMCSR.
When performing a Page Erase of the RWW section, the NRWW section can be read during the operation. When
performing a Page Erase of the NRWW section, the CPU is halted during the operation
The CPU is halted during the Page Erase operation.
21.8.3 Page Load
To write an instruction word:
z Set up the address in the Z-pointer
z Set up the data in R1:R0
z Write “00000001” to SPMCSR
z Execute an SPM instruction within four clock cycles after writing SPMCSR
The content of PCWORD in the Z-register is used to address the data in the temporary buffer. The temporary buffer will
auto-erase after a Page Write operation, or by writing the RWWSRE bit in SPMCSR. It is also erased after a system
reset.
Note that it is not possible to write more than one time to each address without erasing the temporary buffer.
If the EEPROM is written in the middle of an SPM Page Load operation, all data loaded will be lost.
21.8.4 Page Write
To execute Page Write:
z Set up the address in the Z-pointer
z Write “00000101” to SPMCSR
z Execute an SPM instruction within four clock cycles after writing SPMCSR
The data in R1 and R0 is ignored. The page address must be written to PCPAGE. Other bits in the Z-pointer must be
written to zero during this operation.
When performing a Page Write of the RWW section, the NRWW section can be read during the operation. When
performing a Page Write of the NRWW section, the CPU is halted during the operation.