Datasheet
177
ATmega323(L)
1457E–11/01
stant Addressing Using the LPM and SPM Instructions” on page 16 and in the
Instruction set Manual.
The algorithm for reading the Fuse Low bits is similar to the one described above for
reading the Lock bits. To read the Fuse Low bits, load the Z pointer with $0000 and set
the BLBSET and SPMEN bits in SPMCR. When an LPM instruction is executed within
five cycles after the BLBSET and SPMEN bits are set in the SPMCR, the value of the
Fuse Low bits will be loaded in the destination register as shown below.
Similarly, when reading the Fuse High bits, load $0003 in the Z pointer. When an LPM
instruction is executed within five cycles after the BLBSET and SPMEN bits are set in
the SPMCR, the value of the Fuse High bits will be loaded in the destination register as
shown below.
Fuse and Lock bits that are programmed, will be read as zero. Fuse and Lock bits that
are unprogrammed, will be read as one.
In all cases, the read value of unused bit positions are undefined.
EEPROM Write Prevents
Writing to SPMCR
Note that an EEPROM write operation will block all software programming to Flash.
Reading the Fuses and Lock bits from software will also be prevented during the
EEPROM write operation. It is recommended that the user checks the status bit (EEWE)
in the EECR register and verifies that the bit is cleared before writing to the SPMCR reg-
ister. If EEPROM writing is performed inside an interrupt routine, the user software
should disable that interrupt before checking the EEWE status bit.
Addressing the Flash During
Self-programming
The Z pointer is used to address the SPM commands.
Z15 always ignored
Z14:Z7 page select, for page erase and page write
Z6:Z1 word select, for filling temp buffer (must be zero during page write operation)
Z0 should be zero for all SPM commands, byte select for the LPM instruction.
The only 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 the operation.
Note that the page erase and page write operation is addressed independently. There-
fore it is of major importance that the Boot Loader software addresses the same page in
both the page erase and page write operation.
The LPM instruction also 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. See
page 16 for a detailed description.
Bit 76543210
Rd
- - BLB12 BLB11 BLB02 BLB01 LB2 LB1
Bit 7 6543 2 1 0
Rd
BODLEVEL BODEN - - CKSEL3 CKSEL2 CKSEL1 CKSEL0
Bit 7 6 5 4 3 2 1 0
Rd
OCDEN JTAGEN SPIEN - EESAVE BOOTSZ1 BOOTSZ0 BOOTRST
Bit 151413121110 9 8
ZH (R31) Z15 Z14 Z13 Z12 Z11 Z10 Z9 Z8
ZL (R30) Z7 Z6 Z5 Z4 Z3 Z2 Z1 Z0
76543210