
- •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

Data Indirect with Displacement
Data Indirect
Data Indirect with Predecrement
1228B–09/01
ATmega161(L)
Figure 13. Data Indirect with Displacement
Data Space
$0000
15 |
0 |
Y OR Z - REGISTER
15 |
10 |
6 |
5 |
0 |
|
|
OP |
n |
|
|
a |
|
|
|
|
|
|
$FFFF
Operand address is the result of the Y- or Z-register contents added to the address contained in six bits of the instruction word.
Figure 14. Data Indirect Addressing
Data Space
$0000
15 |
0 |
X, Y, OR Z - REGISTER
$FFFF
Operand address is the contents of the X-, Y-, or Z-register.
Figure 15. Data Indirect Addressing with Pre-decrement
Data Space
$0000
15 |
0 |
X, Y, OR Z - REGISTER
-1
$FFFF
The X-, Y-, or Z-register is decremented before the operation. Operand address is the decremented contents of the X-, Y-, or Z-register.
15

Data Indirect with Postincrement
Constant Addressing Using
the LPM Instruction
Figure 16. Data Indirect Addressing with Post-increment
Data Space
$0000
15 |
0 |
X, Y, OR Z - REGISTER
1
$FFFF
The X-, Y-, or Z-register is incremented after the operation. Operand address is the contents of the X-, Y-, or Z-register prior to incrementing.
Figure 17. Code Memory Constant Addressing
PROGRAM MEMORY
$000
15 |
1 |
0 |
Z-REGISTER
$1FFF
Constant byte address is specified by the Z-register contents. The 15 MSBs select word address (0 - 8K), the LSB selects low byte if cleared (LSB = 0) or high byte if set (LSB = 1).
Indirect Program Addressing, Figure 18. Indirect Program Memory Addressing |
|||||
IJMP and ICALL |
|
|
PROGRAM MEMORY |
||
|
|
|
|
||
15 |
0 |
|
|
$000 |
|
|
|||||
|
|
|
|||
|
|
|
|
||
|
|
Z-REGISTER |
|
|
|
|
|
|
|
|
|
$1FFF
16 ATmega161(L)
1228B–09/01

ATmega161(L)
Program execution continues at address contained by the Z-register (i.e., the PC is loaded with the contents of the Z-register).
Relative Program Addressing, Figure 19. Relative Program Memory Addressing |
|||||
RJMP and RCALL |
|
|
PROGRAM MEMORY |
||
|
|
|
|
||
|
|
|
|
$000 |
|
|
|
|
|||
15 |
0 |
|
|
|
|
|
|
|
|
|
|
|
|
PC |
|
|
|
|
|
|
|
|
|
15 |
12 |
11 |
0 |
|
|
|
OP |
|
k |
|
|
|
|
|
$1FFF
Direct Program Addressing,
JMP and CALL
Memory Access Times
and Instruction
Execution Timing
1228B–09/01
Program execution continues at address PC + k + 1. The relative address k is -2048 to 2047.
Figure 20. Direct Program Addressing
PROGRAM MEMORY
$0000
31 |
21 20 |
16 |
||
|
|
OP |
|
|
|
|
|
|
|
|
|
16 LSBs |
|
|
|
|
|
|
|
15 |
|
|
0 |
$1FFF
Program execution continues at the address immediate in the instruction words.
This section describes the general access timing concepts for instruction execution and internal memory access.
The AVR CPU is driven by the System Clock Ø, directly generated from the external clock crystal for the chip. No internal clock division is used.
Figure 21 shows the parallel instruction fetches and instruction executions enabled by the Harvard architecture and the fast-access register file concept. This is the basic pipelining concept to obtain up to 1 MIPS per MHz with the corresponding unique results for functions per cost, functions per clocks and functions per power unit.
17

Figure 21. The Parallel Instruction Fetches and Instruction Executions
T1 |
T2 |
T3 |
T4 |
System Clock Ø
1st Instruction Fetch
1st Instruction Execute 2nd Instruction Fetch 2nd Instruction Execute 3rd Instruction Fetch 3rd Instruction Execute 4th Instruction Fetch
Figure 22 shows the internal timing concept for the register file. In a single clock cycle an ALU operation using two register operands is executed and the result is stored back to the destination register.
Figure 22. Single Cycle ALU Operation
T1 |
T2 |
T3 |
T4 |
System Clock Ø
Total Execution Time
Register Operands Fetch
ALU Operation Execute
Result Write Back
The internal data SRAM access is performed in two System Clock cycles as described in Figure 23.
Figure 23. On-chip Data SRAM Access Cycles
T1 |
T2 |
T3 |
T4 |
System Clock Ø
Address |
Prev. Address |
Address |
Data
WR
Data
RD
Read Write
18 ATmega161(L)
1228B–09/01