
- •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)
Sleep Modes
To enter any of the three sleep modes, the SE bit in MCUCR must be set (one) and a SLEEP instruction must be executed. The SM1 bit in the MCUCR register and SM0 bit in the EMCUCR register select which sleep mode (Idle, Power-down or Power-save) will be activated by the SLEEP instruction (see Table 6). If an enabled interrupt occurs while the MCU is in a sleep mode, the MCU awakes. The CPU is then halted for four cycles, it executes the interrupt routine, and resumes execution from the instruction following SLEEP. The contents of the register file, SRAM and I/O memory are unaltered. If a reset occurs during sleep mode, the MCU wakes up and executes from the Reset vector.
Idle Mode |
When the SM1/SM0 bits are set to 00, the SLEEP instruction makes the MCU enter the |
|
Idle mode, stopping the CPU but allowing SPI, UARTs, Analog Comparator, |
|
Timer/Counters, Watchdog, and the Interrupt System to continue operating. This |
|
enables the MCU to wake up from external triggered interrupts as well as internal ones |
|
like the Timer Overflow and UART Receive Complete interrupts. If wake-up from the |
|
Analog Comparator interrupt is not required, the Analog Comparator can be powered |
|
down by setting the ACD bit in the Analog Comparator Control and Status register |
|
(ACSR). This will reduce power consumption in Idle mode. |
Power-down Mode |
When the SM1/SM0 bits are set to 10, the SLEEP instruction makes the MCU enter the |
|
Power-down mode. In this mode, the external oscillator is stopped while the external |
|
interrupts and the Watchdog (if enabled) continue operating. Only an external reset, a |
|
Watchdog reset (if enabled), an external level interrupt on INT0 or INT1, or an external |
|
edge interrupt on INT2 can wake up the MCU. |
|
If INT2 is used for wake-up from Power-down mode, the edge is remembered until the |
|
MCU wakes up. |
|
If a level-triggered interrupt is used for wake-up from Power-down mode, the changed |
|
level must be held for some time to wake up the MCU. This makes the MCU less sensi- |
|
tive to noise. The changed level is sampled twice by the Watchdog oscillator clock, and |
|
if the input has the required level during this time, the MCU will wake up. The period of |
|
the Watchdog oscillator is 1 µs (nominal) at 5.0V and 25°C. The frequency of the Watch- |
|
dog oscillator is voltage-dependent as shown in the Electrical Characteristics section. |
|
When waking up from Power-down mode, a delay from the wake-up condition occurs |
|
until the wake-up becomes effective. This allows the clock to restart and become stable |
|
after having been stopped. The wake-up period is defined by the same CKSEL fuses |
|
that define the reset time-out period. The wake-up period is equal to the clock counting |
|
part of the reset period, as shown in Table 4. If the wake-up condition disappears before |
|
the MCU wakes up and starts to execute, e.g., a low level on INT0 is not held long |
|
enough, the interrupt causing the wake-up will not be executed. |
Power-save Mode |
When the SM1/SM0 bits are 11, the SLEEP instruction makes the MCU enter the |
|
Power-save mode. This mode is identical to Power-down, with one exception. |
|
If Timer/Counter2 is clocked asynchronously, i.e., the AS2 bit in ASSR is set, |
|
Timer/Counter2 will run during sleep. In addition to the Power-down wake-up sources, |
|
the device can also wake up from either Timer Overflow or Output Compare event from |
|
Timer/Counter2 if the corresponding Timer/Counter2 interrupt enable bits are set in |
|
TIMSK and the global interrupt enable bit in SREG is set. |
|
If the asynchronous timer is not clocked asynchronously, Power-down mode is recom- |
|
mended instead of Power-save mode because the contents of the register in the |
|
asynchronous timer should be considered undefined after wake-up in Power-save mode |
|
even if AS2 is 0. |
37
1228B–09/01