
- •Features
- •Pin Configuration
- •Description
- •Block Diagram
- •Pin Descriptions
- •Port A (PA7..PA0)
- •Port B (PB7..PB0)
- •Port C (PC7..PC0)
- •Port D (PD7..PD0)
- •Port E (PE2..PE0)
- •RESET
- •XTAL1
- •XTAL2
- •Crystal Oscillator
- •EEPROM Data Memory
- •SRAM Data Memory
- •I/O Direct
- •Data Direct
- •Data Indirect with Displacement
- •Data Indirect
- •l/O Memory
- •Status Register – SREG
- •Stack Pointer – SP
- •Reset Sources
- •Power-on Reset
- •External Reset
- •Brown-out Detection
- •Watchdog Reset
- •Interrupt Handling
- •Interrupt Response Time
- •External Interrupts
- •Sleep Modes
- •Idle Mode
- •Power-down Mode
- •Power-save Mode
- •Timer/Counters
- •Timer Counter0 – TCNT0
- •Timer/Counter2 – TCNT2
- •Timer/Counter1
- •Timer/Counter1 in PWM Mode
- •Watchdog Timer
- •SS Pin Functionality
- •Data Modes
- •SPI Control Register – SPCR
- •SPI Status Register – SPSR
- •SPI Data Register – SPDR
- •UARTs
- •Data Transmission
- •Data Reception
- •UART Control
- •Baud Rate Generator
- •Analog Comparator
- •Interface to External Memory
- •I/O Ports
- •Port A
- •Port A Data Register – PORTA
- •Port A as General Digital I/O
- •Port A Schematics
- •Port B
- •Port B Data Register – PORTB
- •Port B as General Digital I/O
- •Port B Schematics
- •Port C
- •Port C Data Register – PORTC
- •Port C as General Digital I/O
- •Port C Schematics
- •Port D
- •Port D Data Register – PORTD
- •Port D as General Digital I/O
- •Alternate Functions of Port D
- •Port D Schematics
- •Port E
- •Port E Data Register – PORTE
- •Port E as General Digital I/O
- •Alternate Functions of Port E
- •Port E Schematics
- •Boot Loader Support
- •Setting the Boot Loader Lock Bits by SPM
- •Performing Page Erase by SPM
- •Fill the Temporary Buffer
- •Perform a Page Write
- •Reading the Fuse and Lock Bits from Software
- •Fuse Bits
- •Signature Bytes
- •Parallel Programming
- •Signal Names
- •Enter Programming Mode
- •Chip Erase
- •Programming the Flash
- •Programming the EEPROM
- •Reading the Flash
- •Reading the EEPROM
- •Programming the Fuse Bits
- •Programming the Lock Bits
- •Reading the Signature Bytes
- •Serial Downloading
- •Data Polling Flash
- •Data Polling EEPROM
- •Electrical Characteristics
- •Absolute Maximum Ratings*
- •External Data Memory Timing
- •Ordering Information
- •Packaging Information

ATmega161(L)
Reading the Fuse and Lock Bits from Software
It is possible to read both the Fuse and Lock bits from software. To read the Lock bits, load the Z-pointer with $0001 and set the BLBSET and SPMEN bits in SPMCR. If an LPM instruction is executed within three CPU cycles after the BLBSET and SPMEN bits are set in SPMCR, the Lock bits will be written to the destination register. The BLBSET and SPMEN bits will auto-clear upon completion of reading the Lock bits or if no LPM/SPM instruction is executed within three/four CPU cycles. When BLBSET and SPMEN are cleared, LPM will work as described in “Constant Addressing Using the LPM Instruction” on page 16 and in the Instruction Set manual.
Bit |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
|
|
– |
– |
BLB12 |
BLB11 |
BLB02 |
BLB01 |
LB2 |
LB1 |
R0/Rd |
|
|
|
|
|
|
|
|
|
|
The algorithm for reading the Fuse bits is similar to the one described above for reading the Lock bits. But when reading the Fuse bits, load $0000 in the Z-pointer. When an LPM instruction is executed within three cycles after the BLBSET and SPMEN bits are set in the SPMCR, the Fuse bits can be read in the destination register as shown below.
Bit |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
|
|
– |
BOOTRST |
SPIEN |
BODLEVEL |
BODEN |
CKSEL[2] |
CKSEL[1] |
CKSEL[0] |
R0/Rd |
|
|
|
|
|
|
|
|
|
|
Fuse and Lock bits that are programmed will be read as zero.
113
1228B–09/01

Program Memory
Lock Bits
Fuse Bits
The ATmega161 MCU provides six Lock bits that can be left unprogrammed (“1”) or can be programmed (“0”) to obtain the additional features listed in Table 40. The Lock bits can only be erased to “1” with the Chip Erase command.
Table 40. Lock Bit Protection Modes (1)
Memory Lock Bits |
|
||
|
|
|
|
LB Mode |
LB1 |
LB2 |
Protection Type |
|
|
|
|
1 |
1 |
1 |
No memory lock features enabled |
|
|
|
|
2 |
0 |
1 |
Further programming of the Flash and EEPROM is |
|
|
|
disabled in parallel and serial programming modes. The |
|
|
|
Fuse bits are locked in both serial and parallel |
|
|
|
programming modes.(1) |
3 |
0 |
0 |
Further programming and verification of the Flash and |
|
|
|
EEPROM is disabled in parallel and serial programming |
|
|
|
modes. The Fuse bits are locked in both serial and parallel |
|
|
|
programming modes.(1) |
BLB0 Mode |
BLB02 |
BLB01 |
|
|
|
|
|
1 |
1 |
1 |
No restrictions for SPM, LPM accessing the Application |
|
|
|
Code section |
|
|
|
|
2 |
1 |
0 |
SPM is not allowed to write to the Application Code |
|
|
|
section. |
|
|
|
|
3 |
0 |
0 |
SPM is not allowed to write to the Application Code |
|
|
|
section and LPM executing from Boot Loader section is |
|
|
|
not allowed to read from the Application Code section. |
|
|
|
|
4 |
0 |
1 |
LPM executing from the Boot Loader section is not |
|
|
|
allowed to read from the Application Code section. |
|
|
|
|
BLB1 Mode |
BLB12 |
BLB11 |
|
|
|
|
|
1 |
1 |
1 |
No restrictions for SPM, LPM accessing the Boot Loader |
|
|
|
section |
|
|
|
|
2 |
1 |
0 |
SPM is not allowed to write the Boot Loader section. |
|
|
|
|
3 |
0 |
0 |
SPM is not allowed to write to the Boot Loader section and |
|
|
|
LPM executing from the Application Code section is not |
|
|
|
allowed to read from the Boot Loader section. |
|
|
|
|
4 |
0 |
1 |
LPM executing from the Application Code section is not |
|
|
|
allowed to read from the Boot Loader section. |
|
|
|
|
Note: 1. Program the Fuse bits before programming the Lock bits.
The ATmega161 has seven Fuse bits: BOOTRST, SPIEN, BODLEVEL, BODEN and CKSEL [2:0].
•When BOOTRST is programmed (“0”), the reset vector is set to address $1E00, which is the first address location in the Boot Loader section of the Flash. If the BOOTRST is unprogrammed (“1”), the reset vector is set to address $0000. Default value is unprogrammed (“1”).
•When the SPIEN Fuse is programmed (“0”), Serial Program and Data Downloading is enabled. Default value is programmed (“0”). The SPIEN Fuse is not accessible in serial programming mode.
114 ATmega161(L)
1228B–09/01