atmega163l ATMEL Corporation, atmega163l Datasheet - Page 136

no-image

atmega163l

Manufacturer Part Number
atmega163l
Description
Atmega163 8-bit Avr Microcontroller With 16k Bytes Of In-system Programmable Flash
Manufacturer
ATMEL Corporation
Datasheet

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
atmega163l-4AI
Manufacturer:
ATMEL
Quantity:
984
Entering the Boot Loader
Program
Capabilities of the Boot
Loader
Self-Programming the
Flash
Performing Page Erase by
SPM
Fill the Temporary Buffer
(Page Load)
136
ATmega163(L)
The SPM instruction can access the entire Flash, but can only be executed from the
Boot Loader Flash section. If no Boot Loader capability is needed, the entire Flash is
available for application code. Entering the Boot Loader takes place by a jump or call
from the application program. This may be initiated by some trigger such as a command
received via UART or SPI interface, for example. Alternatively, the Boot Reset Fuse can
be programmed so that the Reset Vector is pointing to the Boot Flash start address after
a reset. In this case, the Boot Loader is started after a reset. After the application code is
loaded, the program can start executing the application code. Note that the fuses cannot
be changed by the MCU itself. This means that once the Boot Reset Fuse is pro-
grammed, the Reset Vector will always point to the Boot Loader Reset and the fuse can
only be changed through the serial or parallel programming interface.
Table 52. Boot Reset Fuse
The program code within the Boot Loader section has the capability to read from and
write into the entire Flash, including the Boot Loader memory. This allows the user to
update both the Application code and the Boot Loader code that handles the software
update. The Boot Loader can thus even modify itself, and it can also erase itself from
the code if the feature is not needed anymore.
Programming of the Flash is executed one page at a time. The Flash page must be
erased first for correct programming. The general Write Lock (Lock bit 2) does not con-
trol the programming of the Flash memory by SPM instruction. Similarly, the general
Read/Write Lock (Lock bit 1) does not control reading nor writing by LPM/SPM, if it is
attempted.
The Program memory can only be updated page by page, not word by word. One page
is 128 bytes (64 words). The Program memory will be modified by first performing Page
Erase, then filling the temporary page buffer one word at a time using SPM, and
then executing Page Write. If only part of the page needs to be changed, the other
parts must be stored (for example in internal SRAM) before the erase, and then be re-
written. The temporary page buffer can be accessed in a random sequence. It is essen-
tial that the page address used in both the Page Erase and Page Write operation is
addressing the same page. See “Assembly code example for a Boot Loader” on page
141 for an assembly code example.
Se e Table 60 on p age 156 for typical p rogr amming times w hen usin g Self-
Programming.
To execute Page Erase, set up the address in the Z-pointer, write “00011” to the five
LSB in SPMCR and execute SPM within four clock cycles after writing SPMCR. The
data in R1 and R0 is ignored. The page address must be written to Z13:Z7. Other bits in
the Z-pointer will be ignored during this operation. It is recommended that the interrupts
are disabled during the page erase operation.
To write an instruction word, set up the address in the Z-pointer and data in R1:R0, write
“00001” to the five LSB in SPMCR and execute SPM within four clock cycles after writ-
ing SPMCR. The content of Z6:Z1 is used to address the data in the temporary buffer.
Z13:Z7 must point to the page that is supposed to be written.
BOOTRST
1
0
Reset Address
Reset Vector = Application Reset (address $0000)
Reset Vector = Boot Loader Reset (see Table 51)
1142E–AVR–02/03

Related parts for atmega163l