ATMEGA161-8PI Atmel, ATMEGA161-8PI Datasheet - Page 112
![IC AVR MCU 16K 8MHZ IND 40-DIP](/photos/6/70/67049/453-40-dip_sml.jpg)
ATMEGA161-8PI
Manufacturer Part Number
ATMEGA161-8PI
Description
IC AVR MCU 16K 8MHZ IND 40-DIP
Manufacturer
Atmel
Series
AVR® ATmegar
Datasheet
1.ATMEGA161-8AC.pdf
(159 pages)
Specifications of ATMEGA161-8PI
Core Processor
AVR
Core Size
8-Bit
Speed
8MHz
Connectivity
SPI, UART/USART
Peripherals
POR, PWM, WDT
Number Of I /o
35
Program Memory Size
16KB (8K x 16)
Program Memory Type
FLASH
Eeprom Size
512 x 8
Ram Size
1K x 8
Voltage - Supply (vcc/vdd)
4 V ~ 5.5 V
Oscillator Type
External
Operating Temperature
-40°C ~ 85°C
Package / Case
40-DIP (0.600", 15.24mm)
Lead Free Status / RoHS Status
Contains lead / RoHS non-compliant
Data Converters
-
Other names
ATMEGA1618PI
Capabilities of the Boot
Loader
Self-programming the
Flash
Setting the Boot Loader Lock
bits by SPM
Performing Page Erase by
SPM
112
ATmega161(L)
Table 39. Boot Reset Fuse, BOOTRST
Note:
The program code within the Boot Loader section has the ability 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. Special care must be taken if the user allows the
Boot Loader section to be updated by leaving Boot Lock bit11 unprogrammed. An acci-
dental write to the Boot Loader itself can corrupt the entire Boot Loader, and further
software updates might be impossible. If it is not needed to change the Boot Loader
software itself, it is recommended that the Boot Lock bit 11 be programmed to protect
the Boot Loader software from software changes.
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 Read/Write
Lock (Lock Bit 1) does not control reading or 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 by filling the temporary page buffer one word at a time using SPM, and then
by executing page write. If only part of the page needs to be changed, the other parts
must be stored (for example, in the temporary page buffer) before the erase, and then
be rewritten. The temporary page buffer can be accessed in a random sequence. The
CPU is halted both during page erase and during page write and the SPMEN bit in the
SPMCR Register will be auto-cleared. For future compatibility, however, it is recom-
mended that the user software verify that the SPMEN bit is cleared before starting a new
page erase, page write, or before writing the Lock bits command (see code examples
below). It is essential that the page address used in both the page erase and page write
operation is addressing the same page.
To set the Boot Loader Lock bits, write the desired data to R0, write “1001” to SPMCR,
and execute SPM within four clock cycles after writing SPMCR. The only accessible
Lock bits are the Boot Lock bits that may prevent the Application Code and Boot Loader
sections from any software update by the MCU. See Table 37 and Table 38 for how the
different settings of the Boot Loader bits affect the Flash access.
Bit
If bit5 - bit2 in R0 is cleared (zero), the corresponding Boot Lock bit will be programmed
if an SPM instruction is executed within four cycles after BLBSET and SPMEN are set in
SPMCR.
To execute a page erase, set up the address in the Z-pointer, write “0011” to SPMCR,
and execute SPM within four clock cycles after writing SPMCR. The data in R1 and R0
are ignored. The page address must be written to Z13:Z7. Other bits in the Z-pointer will
be ignored during this operation.
BOOTRST
1. “1” means unprogrammed, “0” means programmed
1
0
7
–
Reset Address
Reset Vector = Application Reset (address $0000)
Reset Vector = Boot Loader Reset (address $1E00)
6
–
BLB12
5
BLB11
(1)
4
BLB02
3
BLB01
2
1
–
1228D–AVR–02/07
0
–
R0