Performing A; Addressing The Flash During Self-Programming - Atmel ATtiny25 Manual

Microcontroller with 2/4/8k bytes in-system programmable flash
Table of Contents

Advertisement

20.3
Performing a Page Write
20.4

Addressing the Flash During Self-Programming

7598H–AVR–07/09
To execute Page Write, set up the address in the Z-pointer, write "00000101" to SPMCSR and
execute SPM 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.
• The CPU is halted during the Page Write operation.
The Z-pointer is used to address the SPM commands.
Bit
15
ZH (R31)
Z15
ZL (R30)
Z7
7
Since the Flash is organized in pages (see
be treated as having two different sections. One section, consisting of the least significant bits, is
addressing the words within a page, while the most significant bits are addressing the pages.
This is shown in
Figure
addressed independently. Therefore it is of major importance that the software addresses the
same page in both the Page Erase and Page Write operation.
The LPM instruction uses the Z-pointer to store the address. Since this instruction addresses the
Flash byte-by-byte, also the LSB (bit Z0) of the Z-pointer is used.
Figure 20-1. Addressing the Flash During SPM
BIT
15
ZPCMSB
Z - REGISTER
PROGRAM
COUNTER
PAGE ADDRESS
WITHIN THE FLASH
PROGRAM MEMORY
PAGE
Note:
1. The different variables used in
14
13
12
Z14
Z13
Z12
Z6
Z5
Z4
6
5
4
Table 21-6 on page
20-1. Note that the Page Erase and Page Write operations are
ZPAGEMSB
PCMSB
PAGEMSB
PCPAGE
PCWORD
Figure 20-1
ATtiny25/45/85
11
10
Z11
Z10
Z3
Z2
3
2
137), the Program Counter can
(1)
1
0
0
WORD ADDRESS
WITHIN A PAGE
PAGE
INSTRUCTION WORD
are listed in
Table 21-6 on page
9
8
Z9
Z8
Z1
Z0
1
0
PCWORD[PAGEMSB:0]:
00
01
02
PAGEEND
137.
131

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Attiny45Attiny85

Table of Contents