
- •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)
Reset Sources |
The ATmega161 has four sources of reset: |
||||
|
• Power-on Reset. The MCU is reset when the supply voltage is below the Power-on |
||||
|
Reset threshold (VPOT). |
||||
|
• External Reset. The MCU is reset when a low level is present on the |
|
pin for |
||
|
RESET |
||||
|
more than 500 ns. |
||||
|
• Watchdog Reset. The MCU is reset when the Watchdog timer period expires and |
||||
|
the Watchdog is enabled. |
||||
|
• Brown-out Reset. The MCU is reset when the supply voltage VCC falls below a |
||||
|
certain voltage. |
||||
|
During reset, all I/O registers are then set to their initial values and the program starts |
||||
|
execution from address $000. The instruction placed in address $000 must be a JMP |
||||
|
(relative jump) instruction to the reset handling routine. If the program never enables an |
||||
|
interrupt source, the interrupt vectors are not used and regular program code can be |
||||
|
placed at these locations. The circuit diagram in Figure 24 shows the reset logic. Table 3 |
||||
|
and Table 4 define the timing and electrical parameters of the reset circuitry |
||||
|
Figure 24. Reset Logic |
||||
|
|
DATA BUS |
|
MCU Status
Register (MCUSR)
WDRF |
BORF |
EXTRF |
PORF |
BODEN
Brown-Out
BODLEVEL Reset Circuit
CKSEL[2:0]
Delay Counters
Full
CK
25
1228B–09/01

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Table 3. Reset Characteristics (V = 5.0V)(1) |
|
|
|
|
|
|
|
||||||||||
|
|
|
|
|
|
|
CC |
|
|
|
|
|
|
|
|
|
|
Symbol |
Parameter |
|
Condition |
|
Min |
Typ |
|
Max |
|
Units |
|||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|||||
|
|
Power-on Reset Threshold |
|
BOD disabled |
|
1.0 |
1.4 |
|
1.8 |
|
V |
||||||
|
|
Voltage (rising) |
|
|
|
|
|
|
|
|
|
|
|||||
VPOT |
|
BOD enabled |
|
1.7 |
2.2 |
|
2.7 |
|
V |
||||||||
|
|
|
|
|
|
|
|
|
|
||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
Power-on Reset Threshold |
|
BOD disabled |
|
0.4 |
0.6 |
|
0.8 |
|
V |
||||||||
|
|
|
|
|
|
||||||||||||
|
|
Voltage (falling)(1) |
|
|
|
|
|
|
|
|
|
|
|||||
|
|
|
BOD enabled |
|
1.7 |
2.2 |
|
2.7 |
|
V |
|||||||
|
|
|
|
|
|
|
|
|
|
|
|
||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
|
|
Pin Threshold |
|
|
|
|
|
|
|
|
|
|
|||
VRST |
RESET |
|
|
|
|
|
|
0.85 VCC |
|
V |
|||||||
Voltage |
|
|
|
|
|
|
|
|
|||||||||
VBOT |
Brown-out Reset Threshold |
|
(BODLEVEL = 1) |
|
2.6 |
2.7 |
|
2.8 |
|
V |
|||||||
Voltage |
|
|
|
|
|
|
|
|
|
|
|||||||
|
(BODLEVEL = 0) |
|
3.8 |
4.0 |
|
4.2 |
|
|
|||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|||||
|
|
|
|
|
|
|
|
|
|
||||||||
Note: 1. |
The Power-on Reset will not work unless the supply voltage has been below VPOT |
||||||||||||||||
|
|
(falling). |
|
|
|
|
|
|
|
|
|
||||||
‘ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Table 4. Reset Delay Selections(4) |
|
|
|
|
|
|
|
|
|
||||||||
CKSEL |
|
Start-up Time, VCC = 2.7V, |
Start-up Time, VCC = 4.0V, |
|
Recommended |
||||||||||||
[2:0] |
|
BODLEVEL Unprogrammed |
BODLEVEL Programmed |
|
Usage(1) |
|
|||||||||||
000 |
|
4.2 ms + 6 CK |
5.8 ms + 6 CK |
|
|
|
External Clock, Fast |
||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Rising Power |
|
||
|
|
|
|
|
|
|
|
||||||||||
001 |
|
30 µs + 6 CK |
10 µs + 6 CK |
|
|
|
External Clock, |
||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOD Enabled(2)(3) |
|||
010 |
|
67 ms + 16K CK |
92 ms + 16K CK |
|
|
|
Crystal Oscillator, |
||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Slowly Rising |
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Power |
|
||
|
|
|
|
|
|
|
|
||||||||||
011 |
|
4.2 ms + 16K CK |
5.8 ms + 16K CK |
|
|
|
Crystal Oscillator, |
||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Fast Rising Power |
|||
|
|
|
|
|
|
|
|
||||||||||
100 |
|
30 µs + 16K CK |
10 µs + 16K CK |
|
|
|
Crystal Oscillator, |
||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOD Enabled(2)(3) |
|||
101 |
|
67 ms + 1K CK |
92 ms + 1K CK |
|
|
|
Ceramic |
|
|||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Resonator/External |
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Clock, Slowly Rising |
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Power |
|
||
|
|
|
|
|
|
|
|
||||||||||
110 |
|
4.2 ms + 1K CK |
5.8 ms + 1K CK |
|
|
|
Ceramic Resonator, |
||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Fast Rising Power |
|||
|
|
|
|
|
|
|
|
||||||||||
111 |
|
30 µs + 1K CK |
10 µs + 1K CK |
|
|
|
Ceramic Resonator, |
||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOD Enabled(2)(3) |
Notes: 1. The CKSEL fuses control only the start-up time. The oscillator is the same for all selections. On Power-up, the real-time part of the start-up time is increased with typ.
0.6 ms.
2.Or external Power-on Reset.
3.When BOD is enabled, there will be a real-time part = 50 µs (typ)
4.Table 4 shows the start-up times from reset. From sleep, only the clock counting part of the start-up time is used. The watchdog oscillator is used for timing the real-time part of the start-up time. The number WDT oscillator cycles used for each time-out is shown in Table 5.
26 ATmega161(L)
1228B–09/01

ATmega161(L)
Table 5. Number of Watchdog Oscillator Cycles(1)
BODLEVEL |
Time-out |
Number of Cycles |
|
|
|
Unprogrammed |
4.2 ms (at VCC = 2.7V) |
1K |
|
|
|
Unprogrammed |
67 ms (at VCC = 2.7V) |
16K |
|
|
|
Programmed |
5.8 ms (at VCC = 4.0V) |
4K |
|
|
|
Programmed |
92 ms (at VCC = 4.0V) |
64K |
|
|
|
|
Note: 1. The BOD-LEVEL fuse can be used to select start-up times even if the brown-out |
|||||||||||||
|
|
|
detection is disabled (by leaving the BODEN fuse unprogrammed). |
|||||||||||
|
The frequency of the watchdog oscillator is voltage-dependent as shown in the Electri- |
|||||||||||||
|
cal Characteristics section. The device is shipped with CKSEL = 010. |
|||||||||||||
Power-on Reset |
A Power-on Reset (POR) pulse is generated by an On-chip detection circuit. The detec- |
|||||||||||||
|
tion level is nominally 1.4V (rising VCC). The POR is activated whenever VCC is below |
|||||||||||||
|
the detection level. The POR circuit can be used to trigger the start-up reset, as well as |
|||||||||||||
|
detect a failure in supply voltage. |
|||||||||||||
|
A Power-on Reset (POR) circuit ensures that the device is reset from Power-on. Reach- |
|||||||||||||
|
ing the Power-on Reset threshold voltage invokes a delay counter, which determines |
|||||||||||||
|
the delay, for which the device is kept in RESET after VCC rise. The time-out period of |
|||||||||||||
|
the delay counter can be defined by the user through the CKSEL fuses. The eight differ- |
|||||||||||||
|
ent selections for the delay period are presented in Table 4. The RESET signal is |
|||||||||||||
|
activated again, without any delay, when the VCC decreases below detection level. |
|||||||||||||
|
Figure 25. MCU Start-up, |
|
|
|
Tied to VCC |
|||||||||
|
RESET |
|||||||||||||
|
|
VCC |
|
|
|
|
VPOT |
|||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VRST |
|||||||
|
|
RESET |
|
|
|
|||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TIME-OUT |
|
|
|
|
|
|
tTOUT |
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|||||
|
|
|
|
|
|
|
|
|
|
|||||
|
INTERNAL |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
RESET |
|
|
|
|
|
|
|
|
|
|
|
|
27
1228B–09/01

Figure 26. MCU Start-up, RESET Controlled Externally
|
|
|
|
|
|
|
|
|
VPOT |
|||||||||||||
|
|
|
|
VCC |
||||||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
VRST |
||||||||||
|
|
|
|
|
|
|
|
|||||||||||||||
|
|
|
|
RESET |
||||||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tTOUT |
|
|
|
|
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||||
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||||||
|
|
TIME-OUT |
|
|
|
|||||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||||
|
INTERNAL |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||
External Reset |
|
|
RESET |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||
An External Reset is generated by a low level on the |
|
|
|
pin. Reset pulses longer |
||||||||||||||||||
RESET |
||||||||||||||||||||||
|
than 500 ns will generate a reset, even if the clock is not running. Shorter pulses are not |
|||||||||||||||||||||
|
guaranteed to generate a reset. When the applied signal reaches the Reset Threshold |
|||||||||||||||||||||
|
Voltage (VRST) on its positive edge, the delay timer starts the MCU after the Time-out |
|||||||||||||||||||||
|
period (tTOUT) has expired. |
|||||||||||||||||||||
|
Figure 27. External Reset during Operation |
|||||||||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Brown-out Detection |
ATmega161 has an On-chip Brown-out Detection (BOD) circuit for monitoring the VCC |
|
level during the operation. The BOD circuit can be enabled/disabled by the fuse |
|
BODEN. When BODEN is enabled (BODEN programmed), and VCC decreases to a |
|
value below the trigger level, the Brown-out Reset is immediately activated. When VCC |
|
increases above the trigger level, the Brown-out Reset is deactivated after a delay. The |
|
delay is defined by the user in the same way as the delay of POR signal in Table 4. The |
|
trigger level for the BOD can be selected by the fuse BODLEVEL to be 2.7V |
|
(BODLEVEL unprogrammed), or 4.0V (BODLEVEL programmed). The trigger level has |
|
a hysteresis of 50 mV to ensure spike-free brown-out detection. |
|
The BOD circuit will only detect a drop in VCC if the voltage stays below the trigger level |
|
for longer than 9 µs for trigger level 4.0V, 21 µs for trigger level 2.7V (typical values). |
28 ATmega161(L)
1228B–09/01