ATtiny 461
ATtiny 461
PDIP/SOIC
PB2 (SCK/USCK/SCL/OC1B/PCINT10)
PB0 (MOSI/DI/SDA/OC1A/PCINT8)
PB1 (MISO/DO/OC1A/PCINT9)
PA0 (ADC0/DI/SDA/PCINT0)
PA1 (ADC1/DO/PCINT1)
NC
NC
NC
32
31
30
29
28
27
26
25
NC 1 24 NC
(OC1B/PCINT11) PB3 2 23 PA2 (ADC2/INT1/USCK/SCL/PCINT2)
NC 3 22 PA3 (AREF/PCINT3)
VCC 4 21 AGND
GND 5 QFN/MLF 20 NC
NC 6 19 NC
(ADC7/OC1D/CLKI/XTAL1/PCINT12) PB4 7 18 AVCC
(ADC8/OC1D/CLKO/XTAL2/PCINT13) PB5 8 17 PA4 (ADC3/ICP0/PCINT4)
10
11
12
13
14
15
16
9 NC
(ADC9/INT0/T0/PCINT14) PB6
(ADC10/RESET/PCINT15) PB7
NC
(ADC6/AIN1/PCINT7) PA7
(ADC5/AIN0/PCINT6) PA6
(ADC4/AIN2/PCINT5) PA5
NC
Note: To ensure mechanical stability the center pad underneath the QFN/MLF package should be soldered to ground on the board.
2 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
1.1.1 VCC
Supply voltage.
1.1.2 GND
Ground.
1.1.3 AVCC
Analog supply voltage. This is the supply voltage pin for the Analog-to-digital Converter (ADC),
the analog comparator, the Brown-Out Detector (BOD), the internal voltage reference and Port
A. It should be externally connected to VCC, even if some peripherals such as the ADC are not
used. If the ADC is used AVCC should be connected to VCC through a low-pass filter.
1.1.4 AGND
Analog ground.
1.1.7 RESET
Reset input. A low level on this pin for longer than the minimum pulse length will generate a
reset, even if the clock is not running and provided the reset pin has not been disabled. The min-
imum pulse length is given in Table 19-4 on page 190. Shorter pulses are not guaranteed to
generate a reset.
The reset pin can also be used as a (weak) I/O pin.
3
2588E–AVR–08/10
2. Overview
ATtiny261/461/861 are low-power CMOS 8-bit microcontrollers based on the AVR enhanced
RISC architecture. By executing powerful instructions in a single clock cycle, the
ATtiny261/461/861 achieves throughputs approaching 1 MIPS per MHz allowing the system
designer to optimize power consumption versus processing speed.
VCC
GND
Watchdog Power debugWIRE
Timer Supervision
Watchdog POR / BOD &
PROGRAM
Oscillator RESET LOGIC
CPU
EEPROM
AVCC
AGND
AREF
Internal
USI Analog Comp.
Bandgap
3 11
RESET
XTAL[1..2]
PB[0..7] PA[0..7]
The AVR core combines a rich instruction set with 32 general purpose working registers. All 32
registers are directly connected to the Arithmetic Logic Unit (ALU), allowing two independent
registers to be accessed in one single instruction executed in one clock cycle. The resulting
architecture is more code efficient while achieving throughputs up to ten times faster than con-
ventional CISC microcontrollers.
4 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
The ATtiny261/461/861 provides the following features: 2/4/8K byte of In-System Programmable
Flash, 128/256/512 bytes EEPROM, 128/256/512 bytes SRAM, 16 general purpose I/O lines, 32
general purpose working registers, an 8-bit Timer/Counter with compare modes, an 8-bit high
speed Timer/Counter, a Universal Serial Interface, Internal and External Interrupts, an 11-chan-
nel, 10-bit ADC, a programmable Watchdog Timer with internal oscillator, and four software
selectable power saving modes. Idle mode stops the CPU while allowing the SRAM,
Timer/Counter, ADC, Analog Comparator, and Interrupt system to continue functioning. Power-
down mode saves the register contents, disabling all chip functions until the next Interrupt or
Hardware Reset. ADC Noise Reduction mode stops the CPU and all I/O modules except ADC,
to minimize switching noise during ADC conversions. In Standby mode, the crystal/resonator
oscillator is running while the rest of the device is sleeping, allowing very fast start-up combined
with low power consumption.
The device is manufactured using Atmel’s high density non-volatile memory technology. The
On-chip ISP Flash allows the Program memory to be re-programmed In-System through an SPI
serial interface, by a conventional non-volatile memory programmer or by an On-chip boot code
running on the AVR core.
The ATtiny261/461/861 AVR is supported by a full suite of program and system development
tools including: C Compilers, Macro Assemblers, Program Debugger/Simulators, and Evaluation
kits.
5
2588E–AVR–08/10
3. About
3.1 Resources
A comprehensive set of drivers, application notes, data sheets and descriptions on development
tools are available for download at http://www.atmel.com/avr.
3.4 Disclaimer
Typical values contained in this data sheet are based on simulations and characterization of
other AVR microcontrollers manufactured on the same process technology.
6 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
4. CPU Core
This section discusses the AVR core architecture in general. The main function of the CPU core
is to ensure correct program execution. The CPU must therefore be able to access memories,
perform calculations, control peripherals, and handle interrupts.
Program Status
Flash
Counter and Control
Program
Memory
32 x 8
Instruction General
Register Purpose Interrupt
Registrers Unit
Instruction Watchdog
Decoder Timer
Indirect Addressing
Direct Addressing
ALU Analog
Control Lines Comparator
I/O Module1
I/O Module n
EEPROM
I/O Lines
In order to maximize performance and parallelism, the AVR uses a Harvard architecture – with
separate memories and buses for program and data. Instructions in the Program memory are
executed with a single level pipelining. While one instruction is being executed, the next instruc-
tion is pre-fetched from the Program memory. This concept enables instructions to be executed
in every clock cycle. The Program memory is In-System Reprogrammable Flash memory.
7
2588E–AVR–08/10
The fast-access Register File contains 32 x 8-bit general purpose working registers with a single
clock cycle access time. This allows single-cycle Arithmetic Logic Unit (ALU) operation. In a typ-
ical ALU operation, two operands are output from the Register File, the operation is executed,
and the result is stored back in the Register File – in one clock cycle.
Six of the 32 registers can be used as three 16-bit indirect address register pointers for Data
Space addressing – enabling efficient address calculations. One of the these address pointers
can also be used as an address pointer for look up tables in Flash Program memory. These
added function registers are the 16-bit X-, Y-, and Z-register, described later in this section.
The ALU supports arithmetic and logic operations between registers or between a constant and
a register. Single register operations can also be executed in the ALU. After an arithmetic opera-
tion, the Status Register is updated to reflect information about the result of the operation.
Program flow is provided by conditional and unconditional jump and call instructions, capable of
directly addressing the whole address space. Most AVR instructions have a single 16-bit word
format but 32-bit wide instructions also exist. The actual instruction set varies, as some devices
only implement a part of the instruction set.
During interrupts and subroutine calls, the return address Program Counter (PC) is stored on the
Stack. The Stack is effectively allocated in the general data SRAM, and consequently the Stack
size is only limited by the total SRAM size and the usage of the SRAM. All user programs must
initialize the SP in the Reset routine (before subroutines or interrupts are executed). The Stack
Pointer (SP) is read/write accessible in the I/O space. The data SRAM can easily be accessed
through the five different addressing modes supported in the AVR architecture.
The memory spaces in the AVR architecture are all linear and regular memory maps.
A flexible interrupt module has its control registers in the I/O space with an additional Global
Interrupt Enable bit in the Status Register. All interrupts have a separate Interrupt Vector in the
Interrupt Vector table. The interrupts have priority in accordance with their Interrupt Vector posi-
tion. The lower the Interrupt Vector address, the higher the priority.
The I/O memory space contains 64 addresses for CPU peripheral functions as Control Regis-
ters, SPI, and other I/O functions. The I/O memory can be accessed directly, or as the Data
Space locations following those of the Register File, 0x20 - 0x5F.
8 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
The Status Register is neither automatically stored when entering an interrupt routine, nor
restored when returning from an interrupt. This must be handled by software.
9
2588E–AVR–08/10
4.4 General Purpose Register File
The Register File is optimized for the AVR Enhanced RISC instruction set. In order to achieve
the required performance and flexibility, the following input/output schemes are supported by the
Register File:
• One 8-bit output operand and one 8-bit result input
• Two 8-bit output operands and one 8-bit result input
• Two 8-bit output operands and one 16-bit result input
• One 16-bit output operand and one 16-bit result input
Figure 4-2 below shows the structure of the 32 general purpose working registers in the CPU.
7 0 Addr.
R0 0x00
R1 0x01
R2 0x02
…
R13 0x0D
General R14 0x0E
Purpose R15 0x0F
Working R16 0x10
Registers R17 0x11
…
R26 0x1A X-register Low Byte
R27 0x1B X-register High Byte
R28 0x1C Y-register Low Byte
R29 0x1D Y-register High Byte
R30 0x1E Z-register Low Byte
R31 0x1F Z-register High Byte
Most of the instructions operating on the Register File have direct access to all registers, and
most of them are single cycle instructions.
As shown in Figure 4-2, each register is also assigned a Data memory address, mapping them
directly into the first 32 locations of the user Data Space. Although not being physically imple-
mented as SRAM locations, this memory organization provides great flexibility in access of the
registers, as the X-, Y- and Z-pointer registers can be set to index any register in the file.
15 XH XL 0
X-register 7 0 7 0
R27 (0x1B) R26 (0x1A)
10 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
15 YH YL 0
Y-register 7 0 7 0
R29 (0x1D) R28 (0x1C)
15 ZH ZL 0
Z-register 7 0 7 0
R31 (0x1F) R30 (0x1E)
In different addressing modes these address registers function as automatic increment and
automatic decrement (see the instruction set reference for details).
11
2588E–AVR–08/10
Figure 4-4. The Parallel Instruction Fetches and Instruction Executions
T1 T2 T3 T4
clkCPU
1st Instruction Fetch
1st Instruction Execute
2nd Instruction Fetch
2nd Instruction Execute
3rd Instruction Fetch
3rd Instruction Execute
4th Instruction Fetch
Figure 4-5 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 destina-
tion register.
clkCPU
Total Execution Time
12 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
to be cleared. If an interrupt condition occurs while the corresponding interrupt enable bit is
cleared, the Interrupt Flag will be set and remembered until the interrupt is enabled, or the flag is
cleared by software. Similarly, if one or more interrupt conditions occur while the Global Interrupt
Enable bit is cleared, the corresponding Interrupt Flag(s) will be set and remembered until the
Global Interrupt Enable bit is set, and will then be executed by order of priority.
The second type of interrupts will trigger as long as the interrupt condition is present. These
interrupts do not necessarily have Interrupt Flags. If the interrupt condition disappears before the
interrupt is enabled, the interrupt will not be triggered.
When the AVR exits from an interrupt, it will always return to the main program and execute one
more instruction before any pending interrupt is served.
Note that the Status Register is not automatically stored when entering an interrupt routine, nor
restored when returning from an interrupt routine. This must be handled by software.
When using the CLI instruction to disable interrupts, the interrupts will be immediately disabled.
No interrupt will be executed after the CLI instruction, even if it occurs simultaneously with the
CLI instruction. The following example shows how this can be used to avoid interrupts during the
timed EEPROM write sequence.
When using the SEI instruction to enable interrupts, the instruction following SEI will be exe-
cuted before any pending interrupts, as shown in the following examples.
13
2588E–AVR–08/10
C Code Example
_SEI(); /* set Global Interrupt Enable */
_SLEEP(); /* enter sleep, waiting for interrupt */
/* note: will enter sleep before any pending interrupt(s) */
14 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
5. Memories
This section describes the different memories in the ATtiny261/461/861. The AVR architecture
has two main memory spaces, the Data memory and the Program memory space. In addition,
the ATtiny261/461/861 features an EEPROM Memory for data storage. All three memory
spaces are linear and regular.
0x03FF/0x07FF/0x0FFF
15
2588E–AVR–08/10
When using register indirect addressing modes with automatic pre-decrement and post-incre-
ment, the address registers X, Y, and Z are decremented or incremented.
The 32 general purpose working registers, 64 I/O Registers, and the 128/256/512 bytes of inter-
nal data SRAM in the ATtiny261/461/861 are all accessible through all these addressing modes.
The Register File is described in “General Purpose Register File” on page 10.
Internal SRAM
(128/256/512 x 8)
0x0DF/0x15F/0x25F
clkCPU
Address Compute Address Address valid
Data
Write
WR
Data
Read
RD
16 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
5.3.4 Erase
To erase a byte, the address must be written to EEAR. If the EEPMn bits are 0b01, writing the
EEPE within four cycles after EEMPE is written will trigger the erase operation only (program-
ming time is given in Table 5-1 on page 22). The EEPE bit remains set until the erase operation
completes. While the device is busy programming, it is not possible to do any other EEPROM
operations.
5.3.5 Write
To write a location, the user must write the address into EEAR and the data into EEDR. If the
EEPMn bits are 0b10, writing the EEPE (within four cycles after EEMPE is written) will trigger
the write operation only (programming time is given in Table 5-1 on page 22). The EEPE bit
remains set until the write operation completes. If the location to be written has not been erased
before write, the data that is stored must be considered as lost. While the device is busy with
programming, it is not possible to do any other EEPROM operations.
17
2588E–AVR–08/10
The calibrated Oscillator is used to time the EEPROM accesses. Make sure the Oscillator fre-
quency is within the requirements described in “OSCCAL – Oscillator Calibration Register” on
page 32.
18 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
The next code examples show assembly and C functions for reading the EEPROM. The exam-
ples assume that interrupts are controlled so that no interrupts will occur during execution of
these functions.
19
2588E–AVR–08/10
be used. If a reset occurs while a write operation is in progress, the write operation will be com-
pleted provided that the power supply voltage is sufficient.
20 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
21
2588E–AVR–08/10
old value and program the new value) or to split the Erase and Write operations in two different
operations. The Programming times for the different modes are shown in Table 5-1.
When EEPE is set, any write to EEPMn will be ignored. During reset, the EEPMn bits will be
reset to 0b00 unless the EEPROM is busy programming.
22 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
23
2588E–AVR–08/10
6. Clock System
Figure 6-1 presents the principal clock systems and their distribution in ATtiny261/461/861. All of
the clocks need not be active at a given time. In order to reduce power consumption, the clocks
to modules not being used can be halted by using different sleep modes, as described in “Power
Management and Sleep Modes” on page 36.
clkADC
clkFLASH
Source clock
Watchdog clock
System Clock
Prescaler
Clock Watchdog
Multiplexer Oscillator
clkPCK clkPLL
24 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Table 6-1. Device Clocking Options Select(1) vs. PB4 and PB5 Functionality
Device Clocking Option CKSEL3:0 PB4 PB5
External Clock (see page 26) 0000 XTAL1 I/O
High-Frequency PLL Clock (see page 26) 0001 I/O I/O
Calibrated Internal 8 MHz Oscillator (see page 28) 0010 I/O I/O
Internal 128 kHz Oscillator (see page 29) 0011 I/O I/O
Low-Frequency Crystal Oscillator (see page 29) 01xx XTAL1 XTAL2
Crystal Oscillator / Ceramic Resonator 1000
XTAL1 XTAL2
0.4...0.9 MHz (see page 30) 1001
Crystal Oscillator / Ceramic Resonator 1010
XTAL1 XTAL2
0.9...3.0 MHz (see page 30) 1011
Crystal Oscillator / Ceramic Resonator 1100
XTAL1 XTAL2
3...8 MHz (see page 30) 1101
Crystal Oscillator / Ceramic Resonator 1110
XTAL1 XTAL2
8...20 MHz (see page 30) 1111
Note: 1. For all fuses “1” means unprogrammed and “0” means programmed.
The various choices for each clocking option is given in the following sections. When the CPU
wakes up from Power-down or Power-save, the selected clock source is used to time the start-
up, ensuring stable oscillator operation before instruction execution starts. When the CPU starts
from reset, there is an additional delay allowing the power to reach a stable level before com-
25
2588E–AVR–08/10
mencing normal operation. The watchdog oscillator is used for timing this real-time part of the
start-up time. The number of WD oscillator cycles used for each time-out is shown in Table 6-2.
EXTERNAL
CLOCK CLKI
SIGNAL
GND
When this clock source is selected, start-up times are determined by the SUT Fuses as shown in
Table 6-3.
When applying an external clock, it is required to avoid sudden changes in the applied clock fre-
quency to ensure stable operation of the MCU. A variation in frequency of more than 2% from
one clock cycle to the next can lead to unpredictable behavior. It is required to ensure that the
MCU is kept in Reset during such changes in the clock frequency.
Note that the system clock prescaler can be used to implement run-time changes of the internal
clock frequency. See “System Clock Prescaler” on page 31 for details.
26 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
The fast peripheral clock, clkPCK, can be selected as the clock source for Timer/Counter1 and a
prescaled version of the PLL output, clkPLL, can be selected as system clock. See Figure 6-3 for
a detailed illustration on the PLL clock system.
LOCK
DETECTOR
PLOCK
1/2
4 MHz
8 MHz clkPCK
OSCILLATOR 8 MHz PLL
8x
1/4
64 / 32 MHz 16 MHz
PRESCALER
XTAL1 8 MHz
clkPLL
XTAL2 OSCILLATORS
The internal PLL is enabled when CKSEL fuse bits are programmed to ‘0001’and the PLLE bit of
PLLCSR is set. The internal oscillator and the PLL are switched off in power down and stand-by
sleep modes.
When the LSM bit of PLLCSR is set, the PLL switches from using the output of the internal 8
MHz oscillator to using the output divided by two. The frequency of the fast peripheral clock is
effectively divided by two, resulting in a clock frequency of 32 MHz. The LSM bit can not be set if
PLLCLK is used as a system clock.
Since the PLL is locked to the output of the internal 8 MHz oscillator, adjusting the oscillator fre-
quency via the OSCCAL register also changes the frequency of the fast peripheral clock. It is
possible to adjust the frequency of the internal oscillator to well above 8 MHz but the fast periph-
eral clock will saturate and remain oscillating at about 85 MHz. In this case the PLL is no longer
locked to the internal oscillator clock signal. Therefore, in order to keep the PLL in the correct
operating range, it is recommended to program the OSCCAL registers such that the oscillator
frequency does not exceed 8 MHz.
The PLOCK bit in PLLCSR is set when PLL is locked.
Programming CKSEL fuse bits to ‘0001’, the PLL output divided by four will be used as a system
clock, as shown in Table 6-4.
27
2588E–AVR–08/10
When the PLL output is selected as clock source, the start-up times are determined by SUT fuse
bits as shown in Table 6-5.
When this oscillator is selected, start-up times are determined by SUT fuses as shown in Table
6-7.
Table 6-7. Start-up Times for the Internal Calibrated RC Oscillator Clock Selection
Start-up Time Additional Delay from Recommended
SUT1:0 from Power-down Reset (VCC = 5.0V) Usage
00 6 CK 14CK(1) BOD enabled
01 6 CK 14CK + 4 ms Fast rising power
(2)
10 6 CK 14CK + 64 ms Slowly rising power
11 Reserved
Note: 1. If the RSTDISBL fuse is programmed, this start-up time will be increased to 14CK + 4 ms to
ensure programming mode can be entered.
2. The device is shipped with this option selected.
28 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
It is possible to reach a higher accuracy than factory calibration by changing the OSCCAL regis-
ter from software. See “OSCCAL – Oscillator Calibration Register” on page 32. The accuracy of
this calibration is shown as User calibration in Table 19-2 on page 189.
When this oscillator is used as device clock, the Watchdog Oscillator will still be used for the
Watchdog Timer and for the Reset Time-out. For more information on the pre-programmed cali-
bration value, see section “Calibration Byte” on page 173.
Table 6-8. Start-up Times for the 128 kHz Internal Oscillator
Start-up Time from Power- Additional Delay from
SUT1:0 down and Power-save Reset Recommended Usage
(1)
00 6 CK 14CK BOD enabled
01 6 CK 14CK + 4 ms Fast rising power
10 6 CK 14CK + 64 ms Slowly rising power
11 Reserved
Note: 1. If the RSTDISBL fuse is programmed, this start-up time will be increased to 14CK + 4 ms to
ensure programming mode can be entered.
Table 6-9. Start-up Times for the Low Frequency Crystal Oscillator Clock Selection
Start-up Time Additional Delay
SUT1:0 from Power Down from Reset Recommended usage
(1)
00 1K (1024) CK 4 ms Fast rising power or BOD enabled
01 1K (1024) CK(1) 64 ms Slowly rising power
10 32K (32768) CK 64 ms Stable frequency at start-up
11 Reserved
Notes: 1. These options should be used only if frequency stability at start-up is not important.
The Low-frequency Crystal Oscillator provides an internal load capacitance, see Table 6-10 at
each TOSC pin.
29
2588E–AVR–08/10
6.2.6 Crystal Oscillator / Ceramic Resonator
XTAL1 and XTAL2 are input and output, respectively, of an inverting amplifier which can be con-
figured for use as an On-chip Oscillator, as shown in Figure 6-4. Either a quartz crystal or a
ceramic resonator may be used.
C2
XTAL2
C1
XTAL1
GND
C1 and C2 should always be equal for both crystals and resonators. The optimal value of the
capacitors depends on the crystal or resonator in use, the amount of stray capacitance, and the
electromagnetic noise of the environment. Some initial guidelines for choosing capacitors for
use with crystals are given in Table 6-11. For ceramic resonators, the capacitor values given by
the manufacturer should be used.
Notes: 1. This option should not be used with crystals, only with ceramic resonators.
The Oscillator can operate in three different modes, each optimized for a specific frequency
range. The operating mode is selected by fuses CKSEL3:1 as shown in Table 6-11.
The CKSEL0 Fuse together with the SUT1:0 Fuses select the start-up times as shown in Table
6-12.
Table 6-12. Start-up Times for the Crystal Oscillator Clock Selection
Start-up Time from Additional Delay
Power-down and from Reset
CKSEL0 SUT1:0 Power-save (VCC = 5.0V) Recommended Usage
Ceramic resonator,
0 00 258 CK(1) 14CK + 4 ms
fast rising power
Ceramic resonator,
0 01 258 CK(1) 14CK + 64 ms
slowly rising power
Ceramic resonator,
0 10 1K (1024) CK(2) 14CK
BOD enabled
30 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Table 6-12. Start-up Times for the Crystal Oscillator Clock Selection (Continued)
Start-up Time from Additional Delay
Power-down and from Reset
CKSEL0 SUT1:0 Power-save (VCC = 5.0V) Recommended Usage
Ceramic resonator,
0 11 1K (1024)CK(2) 14CK + 4 ms
fast rising power
Ceramic resonator,
1 00 1K (1024)CK(2) 14CK + 64 ms
slowly rising power
Crystal Oscillator,
1 01 16K (16384) CK 14CK
BOD enabled
Crystal Oscillator,
1 10 16K (16384) CK 14CK + 4 ms
fast rising power
Crystal Oscillator,
1 11 16K (16384) CK 14CK + 64 ms
slowly rising power
Notes: 1. These options should only be used when not operating close to the maximum frequency of the
device, and only if frequency stability at start-up is not important for the application. These
options are not suitable for crystals.
2. These options are intended for use with ceramic resonators and will ensure frequency stability
at start-up. They can also be used with crystals when not operating close to the maximum fre-
quency of the device, and if frequency stability at start-up is not important for the application.
31
2588E–AVR–08/10
From the time the CLKPS values are written, it takes between T1 + T2 and T1 + 2*T2 before the
new clock frequency is active. In this interval, two active clock edges are produced. Here, T1 is
the previous clock period, and T2 is the period corresponding to the new prescaler setting.
32 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
cleared by hardware four cycles after it is written or when the CLKPS bits are written. Rewriting
the CLKPCE bit within this time-out period does neither extend the time-out period, nor clear the
CLKPCE bit.
33
2588E–AVR–08/10
• Bits 6:4 – Res: Reserved Bits
These bits are reserved and will always read as zero.
Interrupts must be disabled when changing prescaler setting to make sure the write procedure is
not interrupted.
The CKDIV8 Fuse determines the initial value of the CLKPS bits. If CKDIV8 is unprogrammed,
the CLKPS bits will be reset to “0000”. If CKDIV8 is programmed, CLKPS bits are reset to
“0011”, giving a division factor of eight at start up. This feature should be used if the selected
clock source has a higher frequency than the maximum frequency of the device at the present
operating conditions. Note that any value can be written to the CLKPS bits regardless of the
CKDIV8 Fuse setting. The Application software must ensure that a sufficient division factor is
chosen if the selcted clock source has a higher frequency than the maximum frequency of the
device at the present operating conditions. The device is shipped with the CKDIV8 Fuse
programmed.
34 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
35
2588E–AVR–08/10
7. Power Management and Sleep Modes
The high performance and industry leading code efficiency makes the AVR microcontrollers an
ideal choise for low power applications. In addition, sleep modes enable the application to shut
down unused modules in the MCU, thereby saving power. The AVR provides various sleep
modes allowing the user to tailor the power consumption to the application’s requirements.
Table 7-1. Active Clock Domains and Wake-up Sources in Different Sleep Modes
Active Clock Domains Osc. Wake-up Sources
Source Enabled
Ready Interrupt
INT0, INT1 and
SPM/EEPROM
Pin Change
Main Clock
Watchdog
Interrupt
Interrupt
Interrupt
clkFLASH
clkCPU
clkADC
clkPCK
Other
clkPLL
ADC
clkIO
USI
I/O
Sleep Mode
Idle X X X X(2) X X X X X X X
(2) (1)
ADC Noise Reduct. X X X X X X X X
Power-down X(1) X X
(1)
Standby X X X
To enter any of the sleep modes, the SE bit in MCUCR must be written to logic one and a
SLEEP instruction must be executed. The SM1:0 bits in the MCUCR Register select which sleep
mode (Idle, ADC Noise Reduction, Power-down, or Standby) will be activated by the SLEEP
instruction. See Table 7-2 for a summary.
If an enabled interrupt occurs while the MCU is in a sleep mode, the MCU wakes up. The MCU
is then halted for four cycles in addition to the start-up time, executes the interrupt routine, and
resumes execution from the instruction following SLEEP. The contents of the Register File and
SRAM are unaltered when the device wakes up from sleep. If a reset occurs during sleep mode,
the MCU wakes up and executes from the Reset Vector.
Note that if a level triggered interrupt is used for wake-up the changed level must be held for
some time to wake up the MCU (and for the MCU to enter the interrupt service routine). See
“External Interrupts” on page 51 for details.
36 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Idle mode enables the MCU to wake up from external triggered interrupts as well as internal
ones like the Timer Overflow. 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. If the
ADC is enabled, a conversion starts automatically when this mode is entered.
37
2588E–AVR–08/10
7.3.1 Analog Comparator
When entering Idle mode, the Analog Comparator should be disabled if not used. When entering
ADC Noise Reduction mode, the Analog Comparator should be disabled. In the other sleep
modes, the Analog Comparator is automatically disabled. However, if the Analog Comparator is
set up to use the Internal Voltage Reference as input, the Analog Comparator should be dis-
abled in all sleep modes. Otherwise, the Internal Voltage Reference will be enabled,
independent of sleep mode. Refer to “AC – Analog Comparator” on page 137 for details on how
to configure the Analog Comparator.
38 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Refer to “DIDR0 – Digital Input Disable Register 0” on page 162 or “DIDR1 – Digital Input Dis-
able Register 1” on page 162 for details.
39
2588E–AVR–08/10
• Bit 2 – PRTIM0: Power Reduction Timer/Counter0
Writing a logic one to this bit shuts down the Timer/Counter0 module. When the Timer/Counter0
is enabled, operation will continue like before the shutdown.
40 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
MCU Status
Register (MCUSR)
PORF
BORF
EXTRF
WDRF
Power-on Reset
Circuit
Brown-out
BODLEVEL [1..0] Reset Circuit
Pull-up Resistor
SPIKE
FILTER
Watchdog
Oscillator
CKSEL[1:0]
SUT[1:0]
The I/O ports of the AVR are immediately reset to their initial state when a reset source goes
active. This does not require any clock source to be running.
After all reset sources have gone inactive, a delay counter is invoked, stretching the internal
reset. This allows the power to reach a stable level before normal operation starts. The time-out
period of the delay counter is defined by the user through the SUT and CKSEL Fuses. The dif-
ferent selections for the delay period are presented in “Clock Sources” on page 25.
41
2588E–AVR–08/10
8.1 Reset Sources
The ATtiny261/461/861 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 RESET pin for longer
than the minimum pulse length.
• 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 is below the Brown-out
Reset threshold (VBOT) and the Brown-out Detector is enabled.
VRST
RESET
tTOUT
TIME-OUT
INTERNAL
RESET
VRST
RESET
tTOUT
TIME-OUT
INTERNAL
RESET
42 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
VCC VBOT+
VBOT-
RESET
TIME-OUT tTOUT
INTERNAL
RESET
43
2588E–AVR–08/10
8.1.4 Watchdog Reset
When the Watchdog times out, it will generate a short reset pulse of one CK cycle duration. On
the falling edge of this pulse, the delay timer starts counting the Time-out period tTOUT. Refer to
“Watchdog Timer” on page 44 for details on operation of the Watchdog Timer.
CK
Thus, when the BOD is not enabled, after setting the ACBG bit or enabling the ADC, the user
must always allow the reference to start up before the output from the Analog Comparator or
ADC is used. To reduce power consumption in Power-down mode, the user can avoid the three
conditions above to ensure that the reference is turned off before entering Power-down mode.
44 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
The Wathdog Timer can also be configured to generate an interrupt instead of a reset. This can
be very helpful when using the Watchdog to wake-up from Power-down.
To prevent unintentional disabling of the Watchdog or unintentional change of time-out period,
two different safety levels are selected by the fuse WDTON as shown in Table 8-1 Refer to
“Timed Sequences for Changing the Configuration of the Watchdog Timer” on page 45 for
details.
OSC/1024K
OSC/512K
OSC/128K
OSC/256K
OSC/16K
OSC/32K
OSC/64K
OSC/2K
OSC/4K
OSC/8K
WATCHDOG
RESET
WDP0
WDP1
WDP2
WDP3
WDE
MCU RESET
8.3.1 Timed Sequences for Changing the Configuration of the Watchdog Timer
The sequence for changing configuration differs slightly between the two safety levels. Separate
procedures are described for each level.
45
2588E–AVR–08/10
1. In the same operation, write a logical one to WDCE and WDE. Even though the WDE
always is set, the WDE must be written to one to start the timed sequence.
2. Within the next four clock cycles, in the same operation, write the WDP bits as desired,
but with the WDCE bit cleared. The value written to the WDE bit is irrelevant.
46 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
47
2588E–AVR–08/10
the next time-out will generate a reset. To avoid the Watchdog Reset, WDIE must be set after
each interrupt.
In safety level 2, it is not possible to disable the Watchdog Timer, even with the algorithm
described above. See “Timed Sequences for Changing the Configuration of the Watchdog
Timer” on page 45.
In safety level 1, WDE is overridden by WDRF in MCUSR. See “MCUSR – MCU Status Regis-
ter” on page 47 for description of WDRF. This means that WDE is always set when WDRF is set.
To clear WDE, WDRF must be cleared before disabling the Watchdog with the procedure
described above. This feature ensures multiple resets during conditions causing failure, and a
safe start-up after the failure.
Note: If the watchdog timer is not going to be used in the application, it is important to go through a
watchdog disable procedure in the initialization of the device. If the Watchdog is accidentally
enabled, for example by a runaway pointer or brown-out condition, the device will be reset, which
in turn will lead to a new watchdog reset. To avoid this situation, the application software should
always clear the WDRF flag and the WDE control bit in the initialization routine.
48 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Notes: 1. If selected, one of the valid settings below 0b1010 will be used.
49
2588E–AVR–08/10
9. Interrupts
This section describes the specifics of the interrupt handling as performed in ATtiny261/461/861.
For a general explanation of the AVR interrupt handling, refer to “Reset and Interrupt Handling”
on page 12.
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 most typical and general program setup for the Reset and Interrupt Vector Addresses in
ATtiny261/461/861 is shown in the program example below.
Address Labels Code Comments
50 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
51
2588E–AVR–08/10
rupt will be generated. The start-up time is defined by the SUT and CKSEL Fuses as described
in “Clock System” on page 24.
If the low level on the interrupt pin is removed before the device has woken up then program
execution will not be diverted to the interrupt service routine but continue from the instruction fol-
lowing the SLEEP command.
52 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Control Register (MCUCR) define whether the external interrupt is activated on rising and/or fall-
ing edge of the INT0 pin or level sensed. Activity on the pin will cause an interrupt request even
if INT0 is configured as an output. The corresponding interrupt of External Interrupt Request 0 is
executed from the INT0 Interrupt Vector.
53
2588E–AVR–08/10
9.3.4 PCMSK0 – Pin Change Mask Register A
Bit 7 6 5 4 3 2 1 0
0x23 (0x43) PCINT7 PCINT6 PCINT5 PCINT4 PCINT3 PCINT2 PCINT1 PCINT0 PCMSK0
Read/Write R/W R/W R/W R/w R/W R/W R/W R/W
Initial Value 1 1 0 0 1 0 0 0
54 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
RPU
Pxn Logic
CPIN
See Figure
"General Digital I/O" for
Details
All registers and bit references in this section are written in general form. A lower case “x” repre-
sents the numbering letter for the port, and a lower case “n” represents the bit number. However,
when using the register or bit defines in a program, the precise form must be used. For example,
PORTB3 for bit no. 3 in Port B, here documented generally as PORTxn. The physical I/O Regis-
ters and bit locations are listed in “Register Description” on page 69.
Three I/O memory address locations are allocated for each port, one each for the Data Register
– PORTx, Data Direction Register – DDRx, and the Port Input Pins – PINx. The Port Input Pins
I/O location is read only, while the Data Register and the Data Direction Register are read/write.
However, writing a logic one to a bit in the PINx Register, will result in a toggle in the correspond-
ing bit in the Data Register. In addition, the Pull-up Disable – PUD bit in MCUCR disables the
pull-up function for all pins in all ports when set.
Using the I/O port as General Digital I/O is described in “Ports as General Digital I/O” on page
56. Most port pins are multiplexed with alternate functions for the peripheral features on the
device. How each alternate function interferes with the port pin is described in “Alternate Port
Functions” on page 60. Refer to the individual module sections for a full description of the alter-
nate functions.
Note that enabling the alternate function of some of the port pins does not affect the use of the
other pins in the port as general digital I/O.
55
2588E–AVR–08/10
10.1 Ports as General Digital I/O
The ports are bi-directional I/O ports with optional internal pull-ups. Figure 10-2 shows a func-
tional description of one I/O-port pin, here generically called Pxn.
PUD
Q D
DDxn
Q CLR
WDx
RESET
RDx
DATA BUS
1
Pxn Q D
PORTxn 0
Q CLR
RESET
WRx WPx
SLEEP RRx
SYNCHRONIZER
RPx
D Q D Q
PINxn
L Q Q
clk I/O
Note: 1. WRx, WPx, WDx, RRx, RPx, and RDx are common to all pins within the same port. clkI/O,
SLEEP, and PUD are common to all ports.
56 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
be configured as an output pin. The port pins are tri-stated when reset condition becomes active,
even if no clocks are running.
If PORTxn is written logic one when the pin is configured as an output pin, the port pin is driven
high (one). If PORTxn is written logic zero when the pin is configured as an output pin, the port
pin is driven low (zero).
The pull-up resistor is activated, if the PUExn is written logic one. To switch the pull-up resistor
off, PUExn has to be written logic zero.
57
2588E–AVR–08/10
Figure 10-3. Synchronization when Reading an Externally Applied Pin value
SYSTEM CLK
SYNC LATCH
PINxn
t pd, max
t pd, min
Consider the clock period starting shortly after the first falling edge of the system clock. The latch
is closed when the clock is low, and goes transparent when the clock is high, as indicated by the
shaded region of the “SYNC LATCH” signal. The signal value is latched when the system clock
goes low. It is clocked into the PINxn Register at the succeeding positive clock edge. As indi-
cated by the two arrows tpd,max and tpd,min, a single signal transition on the pin will be delayed
between ½ and 1½ system clock period depending upon the time of assertion.
When reading back a software assigned pin value, a nop instruction must be inserted as indi-
cated in Figure 10-4. The out instruction sets the “SYNC LATCH” signal at the positive edge of
the clock. In this case, the delay tpd through the synchronizer is one system clock period.
SYSTEM CLK
r16 0xFF
SYNC LATCH
PINxn
t pd
58 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Note: Two temporary registers are used to minimize the time from pull-ups are set on pins 0, 1 and 4,
until the direction bits are correctly set, defining bit 2 and 3 as low and redefining bits 0 and 1 as
strong high drivers.
59
2588E–AVR–08/10
C Code Example
unsigned char i;
...
/* Define pull-ups and set outputs high */
/* Define directions for port pins */
PORTB = (1<<PB4)|(1<<PB1)|(1<<PB0);
DDRB = (1<<DDB3)|(1<<DDB2)|(1<<DDB1)|(1<<DDB0);
/* Insert nop for synchronization*/
_NOP();
/* Read port pins */
i = PINB;
...
60 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
PUOExn
PUOVxn
1
0
PUD
DDOExn
DDOVxn
1
0 Q D
DDxn
Q CLR
WDx
PVOExn RESET
RDx
PVOVxn
DATA BUS
1 1
Pxn
0 Q D 0
PORTxn
PTOExn
Q CLR
DIEOExn
WPx
DIEOVxn RESET
1 WRx
RRx
0 SLEEP
SYNCHRONIZER
RPx
SET
D Q D Q
PINxn
L CLR Q CLR Q
clk I/O
DIxn
AIOxn
Note: 1. WRx, WPx, WDx, RRx, RPx, and RDx are common to all pins within the same port. clkI/O,
SLEEP, and PUD are common to all ports. All other signals are unique for each pin.
61
2588E–AVR–08/10
Table 10-2 summarizes the function of the overriding signals. The pin and port indexes from Fig-
ure 10-5 are not shown in the succeeding tables. The overriding signals are generated internally
in the modules having the alternate function.
The following subsections shortly describe the alternate functions for each port, and relate the
overriding signals to the alternate function. Refer to the alternate function description for further
details.
62 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
63
2588E–AVR–08/10
• Port A, Bit 5 – ADC4/AIN2/PCINT5
• ADC4: Analog to Digital Converter, Channel 4.
• AIN2: Analog Comparator Input. Configure the port pin as input with the internal pull-up
switched off to avoid the digital port function from interfering with the function of the Analog
Comparator.
• PCINT5: Pin Change Interrupt source 5.
64 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Table 10-4 and Table 10-5 relate the alternate functions of Port A to the overriding signals
shown in Figure 10-5 on page 61.
65
2588E–AVR–08/10
10.2.2 Alternate Functions of Port B
The Port B pins with alternate function are shown in Table 10-6.
66 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
• ADC10: ADC input Channel 10. Note that ADC input channel 10 uses analog power.
• PCINT15: Pin Change Interrupt source 15.
67
2588E–AVR–08/10
• Port B, Bit 1 – MISO/ DO/ OC1A/ PCINT9
• DO: Three-wire mode Universal Serial Interface Data output. Three-wire mode Data output
overrides PORTB1 value and it is driven to the port when data direction bit DDB1 is set (one).
PORTB1 still enables the pull-up, if the direction is input and PORTB1 is set (one).
• OC1A: Output Compare Match output: The PB1 pin can serve as an external output for the
Timer/Counter1 Compare Match B when configured as an output (DDB1 set). The OC1A pin
is also the output pin for the PWM mode timer function.
• PCINT9: Pin Change Interrupt source 9.
Table 10-7 and Table 10-8 relate the alternate functions of Port B to the overriding signals
shown in Figure 10-5 on page 61.
RSTDISBL(1) •
PUOE 0 INTRC • EXTCLK INTRC
DWEN(1)
PUOV 1 0 0 0
(1)
RSTDISBL •
DDOE 0 INTRC • EXTCLK INTRC
DWEN(1)
PTOE 0 0 0 0
INTRC • EXTCLK +
RSTDISBL + (PCINT5 INTRC + PCINT12 •
DIEOE 0 PCINT4 • PCIE +
• PCIE + ADC9D) PCIE + ADC7D
ADC8D
(INTRC • EXTCLK) +
DIEOV ADC10D ADC9D INTRC • ADC7D
ADC8D
68 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
PUOE 0 0 0 0
PUOV 0 0 0 0
USI_TWO_WIRE • USI_TWO_WIRE •
DDOE 0 0
USIPOS USIPOS
(USI_SCL_HOLD +
(SDA + PORTB0) •
DDOV 0 PORTB2) • DDB2 • 0
DDB0 • USIPOS
USIPOS
OC1A + (DO •
PVOV OC1B OC1B OC1A
USIPOS)
DIEOV 0 0 0 0
AIO
Note: 1. INTRC means that one of the internal RC Oscillators is selected (by the CKSEL fuses),
EXTCK means that external clock is selected (by the CKSEL fuses).
69
2588E–AVR–08/10
10.3.4 PINA – Port A Input Pins Address
Bit 7 6 5 4 3 2 1 0
0x19 (0x39) PINA7 PINA6 PINA5 PINA4 PINA3 PINA2 PINA1 PINA0 PINA
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value N/A N/A N/A N/A N/A N/A N/A N/A
70 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
11. Timer/Counter0
11.1 Features
• Clear Timer on Compare Match (Auto Reload)
• One Input Capture unit
• Four Independent Interrupt Sources (TOV0, OCF0A, OCF0B, ICF0)
• 8-bit Mode with Two Independent Output Compare Units
• 16-bit Mode with One Independent Output Compare Unit
11.2 Overview
Timer/Counter0 is a general purpose 8/16-bit Timer/Counter module, with two/one Output Com-
pare units and Input Capture feature.
The general operation of Timer/Counter0 is described in 8/16-bit mode. A simplified block dia-
gram of the 8/16-bit Timer/Counter is shown in Figure 11-1. CPU accessible I/O Registers,
including I/O bits and I/O pins, are shown in bold. For actual placement of I/O pins, refer to “Pin-
out ATtiny261/461/861 and ATtiny261V/461V/861V” on page 2. Device-specific I/O Register and
bit locations are listed in the “Register Description” on page 84.
( From Prescaler )
TOP
Timer/Counter
TCNTnH TCNTnL =
OCRnB OCRnA
( From Analog
Comparator Ouput )
Edge Noise
Detector Canceler
TCCRnA TCCRnB ICPn
11.2.1 Registers
The Timer/Counter0 Low Byte Register (TCNT0L) and Output Compare Registers (OCR0A and
OCR0B) are 8-bit registers. Interrupt request (abbreviated Int.Req. in Figure 11-1) signals are all
71
2588E–AVR–08/10
visible in the Timer Interrupt Flag Register (TIFR). All interrupts are individually masked with the
Timer Interrupt Mask Register (TIMSK). TIFR and TIMSK are not shown in the figure.
In 16-bit mode one more 8-bit register is available, the Timer/Counter0 High Byte Register
(TCNT0H). Also, in 16-bit mode, there is only one output compare unit as the two Output Com-
pare Registers, OCR0A and OCR0B, are combined to one, 16-bit Output Compare Register,
where OCR0A contains the low byte and OCR0B contains the high byte of the word. When
accessing 16-bit registers, special procedures described in section “Accessing Registers in 16-
bit Mode” on page 80 must be followed.
11.2.2 Definitions
Many register and bit references in this section are written in general form. A lower case “n”
replaces the Timer/Counter number, in this case 0. A lower case “x” replaces the Output Com-
pare Unit, in this case Compare Unit A or Compare Unit B. However, when using the register or
bit defines in a program, the precise form must be used, i.e. TCNT0L for accessing
Timer/Counter0 counter value, and so on.
The definitions in Table 11-1 are also used extensively throughout the document.
11.3.1 Prescaler
The Timer/Counter can be clocked directly by the system clock (by setting the CSn2:0 = 1). This
provides the fastest operation, with a maximum Timer/Counter clock frequency equal to system
clock frequency (fCLK_I/O). Alternatively, one of four taps from the prescaler can be used as a
clock source.
See Figure 11-2 for an illustration of the prescaler unit.
72 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
clk I/O
Clear
PSR0
T0
Synchronization
clkT0
Note: 1. The synchronization logic on the input pins (T0) is shown in Figure 11-3.
The prescaled clock has a frequency of fCLK_I/O/8, fCLK_I/O/64, fCLK_I/O/256, or fCLK_I/O/1024. See
Table 11-4 on page 85 for details.
73
2588E–AVR–08/10
Figure 11-3. T0 Pin Sampling
Tn D Q D Q D Q Tn_sync
(To Clock
Select Logic)
LE
clk I/O
The synchronization and edge detector logic introduces a delay of 2.5 to 3.5 system clock cycles
from an edge has been applied to the T0 pin to the counter is updated.
Enabling and disabling of the clock input must be done when T0 has been stable for at least one
system clock cycle, otherwise it is a risk that a false Timer/Counter clock pulse is generated.
Each half period of the external clock applied must be longer than one system clock cycle to
ensure correct sampling. The external clock must be guaranteed to have less than half the sys-
tem clock frequency (fExtClk < fclk_I/O/2) given a 50/50% duty cycle. Since the edge detector uses
sampling, the maximum frequency of an external clock it can detect is half the sampling fre-
quency (Nyquist sampling theorem). However, due to variation of the system clock frequency
and duty cycle caused by Oscillator source (crystal, resonator, and capacitors) tolerances, it is
recommended that maximum frequency of an external clock source is less than fclk_I/O/2.5.
An external clock source can not be prescaled.
Clock Select
Edge
Tn
clkTn Detector
TCNTn count Control Logic
( From Prescaler )
top
The counter is incremented at each timer clock (clkT0) until it passes its TOP value and then
restarts from BOTTOM. The counting sequence is determined by the setting of the CTC0 bit
located in the Timer/Counter Control Register (TCCR0A). For more details about counting
sequences, see “Modes of Operation” on page 77. clkT0 can be generated from an external or
74 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
internal clock source, selected by the Clock Select bits (CS02:0). When no clock source is
selected (CS02:0 = 0) the timer is stopped. However, the TCNT0 value can be accessed by the
CPU, regardless of whether clkT0 is present or not. A CPU write overrides (has priority over) all
counter clear or count operations. The Timer/Counter Overflow Flag (TOV0) is set when the
counter reaches the maximum value and it can be used for generating a CPU interrupt.
TEMP (8-bit)
Analog
Comparator Noise Edge
ICF0 (Int.Req.)
Canceler Detector
ICP0
The Output Compare Register OCR0A is a dual-purpose register that is also used as an 8-bit
Input Capture Register ICR0. In 16-bit Input Capture mode the Output Compare Register
OCR0B serves as the high byte of the Input Capture Register ICR0. In 8-bit Input Capture mode
the Output Compare Register OCR0B is free to be used as a normal Output Compare Register,
but in 16-bit Input Capture mode the Output Compare Unit cannot be used as there are no free
Output Compare Register(s). Even though the Input Capture register is called ICR0 in this sec-
tion, it is refering to the Output Compare Register(s).
When a change of the logic level (an event) occurs on the Input Capture pin (ICP0), alternatively
on the Analog Comparator output (ACO), and this change confirms to the setting of the edge
detector, a capture will be triggered. When a capture is triggered, the value of the counter
(TCNT0) is written to the Input Capture Register (ICR0). The Input Capture Flag (ICF0) is set at
75
2588E–AVR–08/10
the same system clock as the TCNT0 value is copied into Input Capture Register. If enabled
(TICIE0=1), the Input Capture Flag generates an Input Capture interrupt. The ICF0 flag is auto-
matically cleared when the interrupt is executed. Alternatively the ICF0 flag can be cleared by
software by writing a logical one to its I/O bit location.
76 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
OCF0B, but in 16-bit mode the match can set only the Output Compare Flag OCF0A as there is
only one Output Compare Unit. If the corresponding interrupt is enabled, the Output Compare
Flag generates an Output Compare interrupt. The Output Compare Flag is automatically cleared
when the interrupt is executed. Alternatively, the flag can be cleared by software by writing a log-
ical one to its I/O bit location. Figure 11-5 shows a block diagram of the Output Compare unit.
OCRnx TCNTn
= (8/16-bit Comparator )
OCFnx (Int.Req.)
77
2588E–AVR–08/10
11.7.1 Normal, 8-bit Mode
In Normal 8-bit mode (see Table 11-3), the counter (TCNT0L) is incrementing until it overruns
when it passes its maximum 8-bit value (MAX = 0xFF) and then restarts from the bottom (0x00).
The Overflow Flag (TOV0) is set in the same timer clock cycle as when TCNT0L becomes zero.
The TOV0 Flag in this case behaves like a ninth bit, except that it is only set, not cleared. How-
ever, combined with the timer overflow interrupt that automatically clears the TOV0 Flag, the
timer resolution can be increased by software. There are no special cases to consider in the
Normal 8-bit mode, a new counter value can be written anytime. The Output Compare Unit can
be used to generate interrupts at some given time.
TCNTn
Period 1 2 3 4
An interrupt can be generated each time the counter value reaches the TOP value by using the
OCF0A Flag. If the interrupt is enabled, the interrupt handler routine can be used for updating
the TOP value. However, changing TOP to a value close to BOTTOM when the counter is run-
ning with none or a low prescaler value must be done with care since the CTC mode does not
have the double buffering feature. If the new value written to OCR0A is lower than the current
value of TCNT0, the counter will miss the Compare Match. The counter will then have to count to
its maximum value (0xFF) and wrap around starting at 0x00 before the Compare Match can
occur. As for the Normal mode of operation, the TOV0 Flag is set in the same timer clock cycle
that the counter counts from MAX to 0x00.
78 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
cases to consider in the Normal mode, a new counter value can be written anytime. The Output
Compare Unit can be used to generate interrupts at some given time.
clkI/O
clkTn
(clkI/O /1)
TOVn
Figure 11-8 shows the same timing data, but with the prescaler enabled.
clkI/O
clkTn
(clkI/O /8)
TOVn
Figure 11-9 on page 80 shows the setting of OCF0A and OCF0B in Normal mode.
79
2588E–AVR–08/10
Figure 11-9. Timer/Counter Timing Diagram, Setting of OCF0x, with Prescaler (fclk_I/O/8)
clkI/O
clkTn
(clkI/O /8)
OCFnx
Figure 11-10 shows the setting of OCF0A and the clearing of TCNT0 in CTC mode.
Figure 11-10. Timer/Counter Timing Diagram, CTC mode, with Prescaler (fclk_I/O/8)
clkPCK
clkTn
(clkPCK /8)
TCNTn
TOP - 1 TOP BOTTOM BOTTOM + 1
(CTC)
OCRnx TOP
OCFnx
80 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
The following code examples show how to access the 16-bit timer registers assuming that no
interrupts updates the temporary register. The same principle can be used directly for accessing
the OCR0A/B registers.
Assembly Code Example
...
; Set TCNT0 to 0x01FF
ldi r17,0x01
ldi r16,0xFF
out TCNT0H,r17
out TCNT0L,r16
; Read TCNT0 into r17:r16
in r16,TCNT0L
in r17,TCNT0H
...
C Code Example
unsigned int i;
...
/* Set TCNT0 to 0x01FF */
TCNT0H = 0x01;
TCNT0L = 0xff;
The assembly code example returns the TCNT0H/L value in the r17:r16 register pair.
It is important to notice that accessing 16-bit registers are atomic operations. If an interrupt
occurs between the two instructions accessing the 16-bit register, and the interrupt code
updates the temporary register by accessing the same or any other of the 16-bit timer registers,
then the result of the access outside the interrupt will be corrupted. Therefore, when both the
main code and the interrupt code update the temporary register, the main code must disable the
interrupts during the 16-bit access.
81
2588E–AVR–08/10
The following code examples show how to do an atomic read of the TCNT0 register contents.
Reading any of the OCR0 register can be done by using the same principle.
Assembly Code Example
TIM0_ReadTCNT0:
; Save global interrupt flag
in r18,SREG
; Disable interrupts
cli
; Read TCNT0 into r17:r16
in r16,TCNT0L
in r17,TCNT0H
; Restore global interrupt flag
out SREG,r18
ret
C Code Example
unsigned int TIM0_ReadTCNT0( void )
{
unsigned char sreg;
unsigned int i;
/* Save global interrupt flag */
sreg = SREG;
/* Disable interrupts */
_CLI();
/* Read TCNT0 into i */
i = TCNT0L;
i |= ((unsigned int)TCNT0H << 8);
/* Restore global interrupt flag */
SREG = sreg;
return i;
}
The assembly code example returns the TCNT0H/L value in the r17:r16 register pair.
82 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
The following code examples show how to do an atomic write of the TCNT0H/L register con-
tents. Writing any of the OCR0A/B registers can be done by using the same principle.
Assembly Code Example
TIM0_WriteTCNT0:
; Save global interrupt flag
in r18,SREG
; Disable interrupts
cli
; Set TCNT0 to r17:r16
out TCNT0H,r17
out TCNT0L,r16
; Restore global interrupt flag
out SREG,r18
ret
C Code Example
void TIM0_WriteTCNT0( unsigned int i )
{
unsigned char sreg;
/* Save global interrupt flag */
sreg = SREG;
/* Disable interrupts */
_CLI();
/* Set TCNT0 to i */
TCNT0H = (i >> 8);
TCNT0L = (unsigned char)i;
/* Restore global interrupt flag */
SREG = sreg;
}
The assembly code example requires that the r17:r16 register pair contains the value to be writ-
ten to TCNT0H/L.
83
2588E–AVR–08/10
11.10 Register Description
84 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
If external pin modes are used for the Timer/Counter0, transitions on the T0 pin will clock the
counter even if the pin is configured as an output. This feature allows software control of the
counting.
The Timer/Counter0 Register Low Byte, TCNT0L, gives direct access, both for read and write
operations, to the Timer/Counter unit 8-bit counter. Writing to the TCNT0L Register blocks (dis-
ables) the Compare Match on the following timer clock. Modifying the counter (TCNT0L) while
the counter is running, introduces a risk of missing a Compare Match between TCNT0L and the
OCR0x Registers. In 16-bit mode the TCNT0L register contains the lower part of the 16-bit
Timer/Counter0 Register.
85
2588E–AVR–08/10
11.10.4 TCNT0H – Timer/Counter0 Register High Byte
Bit 7 6 5 4 3 2 1 0
0x14 (0x34) TCNT0H[7:0] TCNT0H
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value 0 0 0 0 0 0 0 0
When 16-bit mode is selected (the TCW0 bit is set to one) the Timer/Counter Register TCNT0H
combined to the Timer/Counter Register TCNT0L gives direct access, both for read and write
operations, to the Timer/Counter unit 16-bit counter. To ensure that both the high and low bytes
are read and written simultaneously when the CPU accesses these registers, the access is per-
formed using an 8-bit temporary high byte register (TEMP). This temporary register is shared by
all the other 16-bit registers. See “Accessing Registers in 16-bit Mode” on page 80
The Output Compare Register A contains an 8-bit value that is continuously compared with the
counter value (TCNT0L). A match can be used to generate an Output Compare interrupt.
In 16-bit mode the OCR0A register contains the low byte of the 16-bit Output Compare Register.
To ensure that both the high and the low bytes are written simultaneously when the CPU writes
to these registers, the access is performed using an 8-bit temporary high byte register (TEMP).
This temporary register is shared by all the other 16-bit registers. See “Accessing Registers in
16-bit Mode” on page 80.
The Output Compare Register B contains an 8-bit value that is continuously compared with the
counter value (TCNT0L in 8-bit mode and TCNTH in 16-bit mode). A match can be used to gen-
erate an Output Compare interrupt.
In 16-bit mode the OCR0B register contains the high byte of the 16-bit Output Compare Regis-
ter. To ensure that both the high and the low bytes are written simultaneously when the CPU
writes to these registers, the access is performed using an 8-bit temporary high byte register
(TEMP). This temporary register is shared by all the other 16-bit registers. See “Accessing Reg-
isters in 16-bit Mode” on page 80.
86 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
if a Compare Match in Timer/Counter0 occurs, i.e., when the OCF0A bit is set in the
Timer/Counter 0 Interrupt Flag Register – TIFR0.
87
2588E–AVR–08/10
• Bit 1 – TOV0: Timer/Counter0 Overflow Flag
The bit TOV0 is set when an overflow occurs in Timer/Counter0. TOV0 is cleared by hardware
when executing the corresponding interrupt handling vector. Alternatively, TOV0 is cleared by
writing a logic one to the flag. When the SREG I-bit, TOIE0 (Timer/Counter0 Overflow Interrupt
Enable), and TOV0 are set, the Timer/Counter0 Overflow interrupt is executed.
88 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
12. Timer/Counter1
12.1 Features
• 8/10-Bit Accuracy
• Three Independent Output Compare Units
• Clear Timer on Compare Match (Auto Reload)
• Glitch Free, Phase and Frequency Correct Pulse Width Modulator (PWM)
• Variable PWM Period
• High Speed Asynchronous and Synchronous Clocking with Dedicated Prescaler
• Independent Dead Time Generators for Each PWM Channel
• Fault Protection Unit Can Disable PWM Output Pins
• Five Independent Interrupt Sources (TOV1, OCF1A, OCD1B, OCF1D, FPF1)
12.2 Overview
Timer/Counter1 is a general purpose high speed Timer/Counter module, with three independent
Output Compare Units, and with PWM support.
The Timer/Counter1 features a high resolution and a high accuracy usage with the lower pres-
caling opportunities. It can also support three accurate and high speed Pulse Width Modulators
using clock speeds up to 64 MHz. In PWM mode Timer/Counter1 and the output compare regis-
ters serve as triple stand-alone PWMs with non-overlapping non-inverted and inverted outputs.
Similarly, the high prescaling opportunities make this unit useful for lower speed functions or
exact timing functions with infrequent actions. A simplified block diagram of the Timer/Counter1
is shown in Figure 12-1.
OCW1A
OCW1B
OCW1D
OCIE1D
OCIE1A
OCIE1B
OCF1A
OCF1D
OCF1B
FPIE1
TOIE1
FPF1
TOV1
T/C INT. MASK T/C INT. FLAG T/C CONTROL T/C CONTROL T/C CONTROL T/C CONTROL
REGISTER (TIMSK) REGISTER (TIFR) REGISTER A (TCCR1A) REGISTER B (TCCR1B) REGISTER C (TCCR1C) REGISTER C (TCCR1D)
COM1D1
COM1D0
COM1A0
COM1B1
COM1B0
COM1A1
COM1A0
COM1B1
COM1B0
COM1A1
WGM10
WGM11
PWM1D
PWM1B
PWM1A
FOC1D
FOC1A
FOC1B
FPNC1
FPEN1
FPAC1
FPES1
FPIE1
PSR1
PSR1
PSR1
CS13
CS11
CS10
CS12
FPF1
CLK
TIMER/COUNTER1 COUNT
(TCNT1) TIMER/COUNTER1 CONTROL LOGIC
CLEAR
DIRECTION
OC1OE5
OC1OE3
OC1OE4
OC1OE2
OC1OE1
OC1OE0
8-BIT OUTPUT COMPARE 8-BIT OUTPUT COMPARE 8-BIT OUTPUT COMPARE 8-BIT OUTPUT COMPARE 2-BIT HIGH BYTE
REGISTER A (OCR1A) REGISTER B (OCR1B) REGISTER C (OCR1C) REGISTER D (OCR1D) REGISTER (TC1H)
8-BIT DATABUS
89
2588E–AVR–08/10
For actual placement of the I/O pins, refer to “Pinout ATtiny261/461/861 and
ATtiny261V/461V/861V” on page 2. The device-specific I/O register and bit locations are listed
in the “Register Description” on page 112.
12.2.1 Speed
The maximum speed of the Timer/Counter1 is 64 MHz. However, if a supply voltage below 2.7
volts is used, it is recommended to use the Low Speed Mode (LSM), because the
Timer/Counter1 is not running fast enough on low voltage levels. In the Low Speed Mode the
fast peripheral clock is scaled down to 32 MHz. For more details about the Low Speed Mode,
see “PLLCSR – PLL Control and Status Register” on page 120.
12.2.2 Accuracy
The Timer/Counter1 is a 10-bit Timer/Counter module that can alternatively be used as an 8-bit
Timer/Counter. The Timer/Counter1 registers are basically 8-bit registers, but on top of that
there is a 2-bit High Byte Register (TC1H) that can be used as a common temporary buffer to
access the two MSBs of the 10-bit Timer/Counter1 registers by the AVR CPU via the 8-bit data
bus, if the 10-bit accuracy is used. Whereas, if the two MSBs of the 10-bit registers are written to
zero the Timer/Counter1 is working as an 8-bit Timer/Counter. When reading the low byte of any
8-bit register the two MSBs are written to the TC1H register, and when writing the low byte of
any 8-bit register the two MSBs are written from the TC1H register. Special procedures must be
followed when accessing the 10-bit Timer/Counter1 values via the 8-bit data bus. These proce-
dures are described in the section “Accessing 10-Bit Registers” on page 108.
12.2.3 Registers
The Timer/Counter (TCNT1) and Output Compare Registers (OCR1A, OCR1B, OCR1C and
OCR1D) are 8-bit registers that are used as a data source to be compared with the TCNT1 con-
tents. The OCR1A, OCR1B and OCR1D registers determine the action on the OC1A, OC1B and
OC1D pins and they can also generate the compare match interrupts. The OCR1C holds the
Timer/Counter TOP value, i.e. the clear on compare match value. The Timer/Counter1 High
Byte Register (TC1H) is a 2-bit register that is used as a common temporary buffer to access the
MSB bits of the Timer/Counter1 registers, if the 10-bit accuracy is used.
Interrupt request (overflow TOV1, and compare matches OCF1A, OCF1B, OCF1D and fault pro-
tection FPF1) signals are visible in the Timer Interrupt Flag Register (TIFR) and Timer/Counter1
Control Register D (TCCR1D). The interrupts are individually masked with the Timer Interrupt
Mask Register (TIMSK) and the FPIE1 bit in the Timer/Counter1 Control Register D (TCCR1D).
Control signals are found in the Timer/Counter Control Registers TCCR1A, TCCR1B, TCCR1C,
TCCR1D and TCCR1E.
12.2.4 Synchronization
In asynchronous clocking mode the Timer/Counter1 and the prescaler allow running the CPU
from any clock source while the prescaler is operating on the fast peripheral clock (PCK) having
frequency of 64 MHz (or 32 MHz in Low Speed Mode). This is possible because there is a syn-
chronization boundary between the CPU clock domain and the fast peripheral clock domain.
Figure 12-2 shows Timer/Counter 1 synchronization register block diagram and describes syn-
chronization delays in between registers. Note that all clock gating details are not shown in the
figure.
The Timer/Counter1 register values go through the internal synchronization registers, which
cause the input synchronization delay, before affecting the counter operation. The registers
90 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
TCCR1A, TCCR1B, TCCR1C, TCCR1D, OCR1A, OCR1B, OCR1C and OCR1D can be read
back right after writing the register. The read back values are delayed for the Timer/Counter1
(TCNT1) register, Timer/Counter1 High Byte Register (TC1H) and flags (OCF1A, OCF1B,
OCF1D and TOV1), because of the input and output synchronization.
The system clock frequency must be lower than half of the PCK frequency, because the syn-
chronization mechanism of the asynchronous Timer/Counter1 needs at least two edges of the
PCK when the system clock is high. If the frequency of the system clock is too high, it is a risk
that data or control values are lost.
TCCR1A TCCR1A_SI
TCCR1B TCCR1B_SI
OCF1A
OCF1A_SO
TCCR1C TCCR1C_SI
TCNT1
TCCR1D TCCR1D_SI
OCF1B
TCNT1 TCNT1_SI OCF1B_SO
TC1H TC1H_SI
OCF1D OCF1D_SI
TOV1
TOV1 TOV1_SI TOV1_SO
PCKE
CK
S
A
S
PCK A
12.2.5 Definitions
Many register and bit references in this section are written in general form. A lower case “n”
replaces the Timer/Counter number, in this case 0. A lower case “x” replaces the Output Com-
pare Unit, in this case Compare Unit A, B, C or D. However, when using the register or bit
defines in a program, the precise form must be used, i.e., TCNT1 for accessing Timer/Counter1
91
2588E–AVR–08/10
counter value and so on. The definitions in Table 12-1 are used extensively throughout the
document.
12.3.1 Prescaler
Figure 12-3 shows the Timer/Counter1 prescaler that supports two clocking modes, a synchro-
nous clocking mode and an asynchronous clocking mode. The synchronous clocking mode uses
the system clock (CK) as a clock timebase and asynchronous mode uses the fast peripheral
clock (PCK) as a clock time base. The PCKE bit from the PLLCSR register enables the asyn-
chronous mode when it is set (‘1’).
CK
S T1CK 14-BIT
PCK 64/32 MHz A T/C PRESCALER
T1CK/16384
T1CK/1024
T1CK/2048
T1CK/4096
T1CK/8192
T1CK/128
T1CK/256
T1CK/512
T1CK/16
T1CK/32
T1CK/64
T1CK/2
T1CK/4
T1CK/8
T1CK
CS10
CS11
CS12
CS13
In the asynchronous clocking mode the clock selections are from PCK to PCK/16384 and stop,
and in the synchronous clocking mode the clock selections are from CK to CK/16384 and stop.
The clock options are illustrated in Figure 12-3 and desribed in “TCCR1B – Timer/Counter1
Control Register B” on page 115.
The frequency of the fast peripheral clock is 64 MHz or 32 MHz in Low Speed mode (the LSM bit
in PLLCSR register is set to one). The Low Speed Mode is recommended to use when the sup-
ply voltage below 2.7 volts are used.
92 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
clkT1
Timer/Counter1 Count Enable
count ( From Prescaler )
TCNT1 clear Control Logic PCKE
PCK
direction
CK
bottom top
Depending on the mode of operation used, the counter is cleared, incremented, or decremented
at each timer clock (clkT1). The timer clock is generated from an synchronous system clock or an
asynchronous PLL clock using the Clock Select bits (CS13:0) and the PCK Enable bit (PCKE).
When no clock source is selected (CS13:0 = 0) the timer is stopped. However, the TCNT1 value
can be accessed by the CPU, regardless of whether clkT1 is present or not. A CPU write over-
rides (has priority over) all counter clear or count operations.
The counting sequence of the Timer/Counter1 is determined by bits WGM11:10, PWM1A and
PWM1B, located in the Timer/Counter1 Control Registers (TCCR1A, TCCR1C and TCCR1D).
For more details about advanced counting sequences and waveform generation, see “Modes of
Operation” on page 99. The Timer/Counter Overflow Flag (TOV1) is set according to the mode
of operation and can be used for generating a CPU interrupt.
93
2588E–AVR–08/10
12.4.1 Counter Initialization for Asynchronous Mode
To set Timer/Counter1 to asynchronous mode follow the procedure below:
1. Enable PLL.
2. Wait 100 µs for PLL to stabilize.
3. Poll the PLOCK bit until it is set.
4. Set the PCKE bit in the PLLCSR register which enables the asynchronous mode.
= (10-bit Comparator )
OCFnx (Int.Req.)
TOP PWMnx
FOCn COMnX1:0
OCWnx
The OCR1x Registers are double buffered when using any of the Pulse Width Modulation
(PWM) modes. For the normal mode of operation, the double buffering is disabled. The double
buffering synchronizes the update of the OCR1x Compare Registers to either top or bottom of
the counting sequence. The synchronization prevents the occurrence of odd-length, non-sym-
94 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
metrical PWM pulses, thereby making the output glitch-free. See Figure 12-6 for an example.
During the time between the write and the update operation, a read from OCR1A, OCR1B,
OCR1C or OCR1D will read the contents of the temporary location. This means that the most
recently written value always will read out of OCR1A, OCR1B, OCR1C or OCR1D.
Output Compare
Synchronized WFnx Latch Waveform OCWnx
Compare Value changes
Counter Value
Compare Value
Output Compare
Unsynchronized WFnx Latch Glitch Wafeform OCWnx
95
2588E–AVR–08/10
12.6 Dead Time Generator
The Dead Time Generator is provided for the Timer/Counter1 PWM output pairs to allow driving
external power control switches safely. The Dead Time Generator is a separate block that can
be used to insert dead times (non-overlapping times) for the Timer/Counter1 complementary
output pairs OC1x and OC1x when the PWM mode is enabled and the COM1x1:0 bits are set to
“01”. See Figure 12-7 below.
Figure 12-7. Block Diagram of Waveform Generator and Dead Time Generator.
CK OR PCK
PWMnx WGM10 COMnx CLOCK DTPSn DTnH DTnL
The tasks are shared as follows: the Waveform Generator generates the output (OCW1x) and
the Dead Time Generator generates the non-overlapping PWM output pair from the output.
Three Dead Time Generators are provided, one for each PWM output. The non-overlap time is
adjustable and the PWM output and it’s complementary output are adjusted separately, and
independently for both PWM outputs.
The Dead Time Generation is based on 4-bit down counters that count the dead time, as shown
in Figure 12-8.
COMPARATOR
OCnx
CK OR PCK
CLOCK
DEAD TIME
CLOCK CONTROL 4-BIT COUNTER
PRE-SCALER
OCnx
DTPSn
DTnH
DTnL
PWM1X
OCWnx
There is a dedicated prescaler in front of the Dead Time Generator that can divide the
Timer/Counter1 clock (PCK or CK) by 1, 2, 4 or 8. This provides for large range of dead times
that can be generated. The prescaler is controlled by two control bits DTPS11:10. The block has
also a rising and falling edge detector that is used to start the dead time counting period.
Depending on the edge, one of the transitions on the rising edges, OC1x or OC1x is delayed
until the counter has counted to zero. The comparator is used to compare the counter with zero
and stop the dead time insertion when zero has been reached. The counter is loaded with a 4-bit
DT1H or DT1L value from DT1 I/O register, depending on the edge of the Waveform Output
(OCW1x) when the dead time insertion is started. The Output Compare Output are delayed by
one timer clock cycle at minimum from the Waveform Output when the Dead Time is adjusted to
96 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
zero. The outputs OC1x and OC1x are inverted, if the PWM Inversion Mode bit PWM1X is set.
This will also cause both outputs to be high during the dead time.
The length of the counting period is user adjustable by selecting the dead time prescaler setting
by using the DTPS11:10 control bits, and selecting then the dead time value in I/O register DT1.
The DT1 register consists of two 4-bit fields, DT1H and DT1L that control the dead time periods
of the PWM output and its' complementary output separately in terms of the number of pres-
caled dead time generator clock cycles. Thus the rising edge of OC1x and OC1x can have
different dead time periods as the tnon-overlap / rising edge is adjusted by the 4-bit DT1H value and the
tnon-overlap / falling edge is adjusted by the 4-bit DT1L value.
OCWnx
OCnx
OCnx
(COMnx = 1)
97
2588E–AVR–08/10
Figure 12-10. Compare Match Output Unit, Schematic
WGM11
clk I/O
OC1OE1:0 Output Compare
COM1A1:0 Pin Configuration
D Q
PORTB0
0
1
1 OC1A
D Q PIN
0
DDRB0
OCW1A OC1A
D Q Dead Time Q
PORTB1 clk Tn 1
Generator A Q OC1A
OC1A
0 PIN
D Q
DDRB1 WGM11
OC1OE3:2 Output Compare
COM1B1:0 Pin Configuration
D Q
PORTB2
2
1 1
0 OC1B
DATA BUS
D Q PIN
0
DDRB2
OCW1B OC1B
D Q 1
Dead Time Q
clk Tn 1
PORTB3 Generator B Q OC1B
0 OC1B
0 PIN
D Q
DDRB3 WGM11
OC1OE5:4 Output Compare
COM1D1:0 Pin Configuration
D Q
PORTB4
2
1 1
0 OC1D
D Q PIN
0
DDRB4
OCW1D OC1D
D Q 1
Dead Time Q
clk Tn OC1D 1
PORTB5 Generator D Q 0 OC1D
0 PIN
D Q
DDRB5
The general I/O port function is overridden by the Output Compare (OC1x / OC1x) from the
Dead Time Generator if either of the COM1x1:0 bits are set. However, the OC1x pin direction
(input or output) is still controlled by the Data Direction Register (DDR) for the port pin. The Data
Direction Register bit for the OC1x and OC1x pins (DDR_OC1x and DDR_OC1x) must be set as
output before the OC1x and OC1x values are visible on the pin. The port override function is
independent of the Output Compare mode.
98 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
The design of the Output Compare Pin Configuration logic allows initialization of the OC1x state
before the output is enabled. Note that some COM1x1:0 bit settings are reserved for certain
modes of operation. For Output Compare Pin Configurations refer to Table 12-2 on page 100,
Table 12-3 on page 102, Table 12-4 on page 104, Table 12-5 on page 105, Table 12-6 on page
105, and Table 12-7 on page 106.
TCNTn
OCWnx
(COMnx=1)
Period 1 2 3 4
99
2588E–AVR–08/10
The counter value (TCNT1) that is shown as a histogram in Figure 12-11 is incremented until the
counter value matches the TOP value. The counter is then cleared at the following clock cycle
The diagram includes the Waveform Output (OCW1x) in toggle Compare Mode. The small hori-
zontal line marks on the TCNT1 slopes represent Compare Matches between OCR1x and
TCNT1.
The Timer/Counter Overflow Flag (TOV1) is set in the same clock cycle as the TCNT1 becomes
zero. The TOV1 Flag in this case behaves like a 11th bit, except that it is only set, not cleared.
However, combined with the timer overflow interrupt, that automatically clears the TOV1 Flag,
the timer resolution can be increased by software. There are no special cases to consider in the
Normal mode, a new counter value can be written anytime.
The Output Compare Unit can be used to generate interrupts at some given time. Using the Out-
put Compare to generate waveforms in Normal mode is not recommended, since this will
occupy too much of the CPU time. For generating a waveform, the OCW1x output can be set to
toggle its logical level on each Compare Match by setting the Compare Output mode bits to tog-
gle mode (COM1x1:0 = 1). The OC1x value will not be visible on the port pin unless the data
direction for the pin is set to output. The waveform generated will have a maximum frequency of
fOC1x = fclkT1/4 when OCR1C is set to zero. The waveform frequency is defined by the following
equation:
f clkT1
f OC1x = -------------------------------------------
2 ⋅ ( 1 + OCR1C )
Resolution, RPWM, shows how many bit is required to express the value in the OCR1C register
and it can be calculated using the following equation:
The Output Compare Pin configurations in Normal Mode are described in Table 12-2.
100 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
DAC applications. High frequency allows physically small sized external components (coils,
capacitors), and therefore reduces total system cost.
The timing diagram for the fast PWM mode is shown in Figure 12-12. The counter is incre-
mented until the counter value matches the TOP value. The counter is then cleared at the
following timer clock cycle. The TCNT1 value is in the timing diagram shown as a histogram for
illustrating the single-slope operation. The diagram includes the Waveform Output in non-
inverted and inverted Compare Output modes. The small horizontal line marks on the TCNT1
slopes represent Compare Matches between OCR1x and TCNT1.
TCNTn
OCWnx
(COMnx1:0 = 2)
OCWnx
(COMnx1:0 = 3)
Period 1 2 3 4 5 6 7
The Timer/Counter Overflow Flag (TOV1) is set each time the counter reaches TOP. If the inter-
rupt is enabled, the interrupt handler routine can be used for updating the compare value.
In fast PWM mode, the compare unit allows generation of PWM waveforms on the OC1x pins.
Setting the COM1x1:0 bits to two will produce a non-inverted PWM and setting the COM1x1:0 to
three will produce an inverted PWM output. Setting the COM1x1:0 bits to one will enable com-
plementary Compare Output mode and produce both the non-inverted (OC1x) and inverted
output (OC1x). The actual value will only be visible on the port pin if the data direction for the
port pin is set as output. The PWM waveform is generated by setting (or clearing) the Waveforn
Output (OCW1x) at the Compare Match between OCR1x and TCNT1, and clearing (or setting)
the Waveform Output at the timer clock cycle the counter is cleared (changes from TOP to
BOTTOM).
The PWM frequency for the output can be calculated by the following equation:
f clkT1
f OCnxPWM = -------------
N
The N variable represents the number of steps in single-slope operation. The value of N equals
either to the TOP value.
The extreme values for the OCR1C Register represents special cases when generating a PWM
waveform output in the fast PWM mode. If the OCR1C is set equal to BOTTOM, the output will
be a narrow spike for each MAX+1 timer clock cycle. Setting the OCR1C equal to MAX will result
101
2588E–AVR–08/10
in a constantly high or low output (depending on the polarity of the output set by the COM1x1:0
bits.)
A frequency (with 50% duty cycle) waveform output in fast PWM mode can be achieved by set-
ting the Waveform Output (OCW1x) to toggle its logical level on each Compare Match
(COM1x1:0 = 1). The waveform generated will have a maximum frequency of fOC1 = fclkT1/4 when
OCR1C is set to three.
The general I/O port function is overridden by the Output Compare value (OC1x / OC1x) from
the Dead Time Generator, if either of the COM1x1:0 bits are set and the Data Direction Register
bits for the OC1X and OC1X pins are set as an output. If the COM1x1:0 bits are cleared, the
actual value from the port register will be visible on the port pin. The Output Compare Pin config-
urations are described in Table 12-3.
102 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Figure 12-13. Phase and Frequency Correct PWM Mode, Timing Diagram
OCRnx Update
TOVn Interrupt Flag Set
TCNTn
OCWnx
(COMnx = 2)
OCWnx
(COMnx = 3)
Period 1 2 3
The Timer/Counter Overflow Flag (TOV1) is set each time the counter reaches BOTTOM. The
Interrupt Flag can be used to generate an interrupt each time the counter reaches the BOTTOM
value.
In the Phase and Frequency Correct PWM mode, the compare unit allows generation of PWM
waveforms on the OC1x pins. Setting the COM1x1:0 bits to two will produce a non-inverted
PWM and setting the COM1x1:0 to three will produce an inverted PWM output. Setting the
COM1A1:0 bits to one will enable complementary Compare Output mode and produce both the
non-inverted (OC1x) and inverted output (OC1x). The actual values will only be visible on the
port pin if the data direction for the port pin is set as output. The PWM waveform is generated by
clearing (or setting) the Waveform Output (OCW1x) at the Compare Match between OCR1x and
TCNT1 when the counter increments, and setting (or clearing) the Waveform Output at Compare
Match when the counter decrements. The PWM frequency for the output when using the Phase
and Frequency Correct PWM can be calculated by the following equation:
f clkT1
f OCnxPCPWM = -------------
N
The N variable represents the number of steps in dual-slope operation. The value of N equals to
the TOP value.
The extreme values for the OCR1C Register represent special cases when generating a PWM
waveform output in the Phase and Frequency Correct PWM mode. If the OCR1C is set equal to
BOTTOM, the output will be continuously low and if set equal to MAX the output will be continu-
ously high for non-inverted PWM mode. For inverted PWM the output will have the opposite
logic values.
The general I/O port function is overridden by the Output Compare value (OC1x / OC1x) from
the Dead Time Generator, if either of the COM1x1:0 bits are set and the Data Direction Register
bits for the OC1X and OC1X pins are set as an output. If the COM1x1:0 bits are cleared, the
103
2588E–AVR–08/10
actual value from the port register will be visible on the port pin. The configurations of the Output
Compare Pins are described in Table 12-4.
Table 12-4. Output Compare pin configurations in Phase and Frequency Correct PWM Mode
COM1x1 COM1x0 OC1x Pin OC1x Pin
0 0 Disconnected Disconnected
0 1 OC1x OC1x
1 0 Disconnected OC1x
1 1 Disconnected OC1x
104 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
TCNT1
OCW1A
OC1OE0
OC1A Pin
OC1OE1
OC1A Pin
OC1OE2
OC1B Pin
OC1OE3
OC1B Pin
OC1OE4
OC1D Pin
OC1OE5
OC1D Pin
The general I/O port function is overridden by the Output Compare value (OC1x / OC1x) from
the Dead Time Generator if either of the COM1x1:0 bits are set. The Output Compare pins can
also be overriden by the Output Compare Override Enable bits OC1OE5:OC1OE0. If an Over-
ride Enable bit is cleared, the actual value from the port register will be visible on the port pin
and, if the Override Enable bit is set, the Output Compare pin is allowed to be connected on the
port pin. The Output Compare Pin configurations are described in Table 12-5, Table 12-6 and
Table 12-7.
Table 12-5. Configuration of Output Compare Pins OC1A and OC1A in PWM6 Mode
COM1A1 COM1A0 OC1A Pin (PB0) OC1A Pin (PB1)
0 0 Disconnected Disconnected
0 1 OC1A • OC1OE0 OC1A • OC1OE1
1 0 OC1A • OC1OE0 OC1A • OC1OE1
1 1 OC1A • OC1OE0 OC1A • OC1OE1
Table 12-6. Configuration of Output Compare Pins OC1B and OC1B in PWM6 Mode
COM1B1 COM1B0 OC1B Pin (PB2) OC1B Pin (PB3)
0 0 Disconnected Disconnected
0 1 OC1A • OC1OE2 OC1A • OC1OE3
1 0 OC1A • OC1OE2 OC1A • OC1OE3
1 1 OC1A • OC1OE2 OC1A • OC1OE3
105
2588E–AVR–08/10
Table 12-7. Configuration of Output Compare Pins OC1D and OC1D in PWM6 Mode
COM1D1 COM1D0 OC1D Pin (PB4) OC1D Pin (PB5)
0 0 Disconnected Disconnected
0 1 OC1A • OC1OE4 OC1A • OC1OE5
1 0 OC1A • OC1OE4 OC1A • OC1OE5
1 1 OC1A • OC1OE4 OC1A • OC1OE5
clkPCK
clkTn
(clkPCK /1)
TOVn
Figure 12-16 shows the same timing data, but with the prescaler enabled, in all modes other
than Phase and Frequency Correct PWM Mode.
clkPCK
clkTn
(clkPCK /8)
TOVn
Figure 12-17 shows the setting of OCF1A, OCF1B and OCF1D in all modes.
106 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Figure 12-17. Timer/Counter Timing Diagram, Setting of OCF1x, with Prescaler (fclkT1/8)
clkPCK
clkTn
(clkPCK /8)
OCFnx
Figure 12-18 shows the setting of TOV1 in Phase and Frequency Correct PWM Mode.
clkPCK
clkTn
(clkPCK /8)
TOVn
Analog
Comparator Noise Edge
Timer/Counter1
Canceler Detector
INT0
Fault Protection mode is enabled by setting the Fault Protection Enable (FPEN1) bit and trig-
gered by a change in logic level at external interrupt pin (INT0). Alternatively, fault protection
mode can be triggered by the Analog Comparator Output (ACO).
When Fault Protection is triggered, the COM1x bits are cleared, Output Comparators are discon-
nected from the PWM output pins and PORTB register bits are connected to the PWM output
107
2588E–AVR–08/10
pins. The Fault Protection Enable (FPEN1) is automatically cleared at the same system clock as
the COM1nx bits are cleared.
If the Fault Protection Interrupt Enable bit (FPIE1) is set, a Fault Protection interrupt is generated
and the FPEN1 bit is cleared. Alternatively the FPEN1 bit can be polled by software to figure out
when the Timer/Counter has entered to Fault Protection mode.
108 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
The assembly code example returns the TCNT1 value in the r17:r16 register pair.
It is important to notice that accessing 10-bit registers are atomic operations. If an interrupt
occurs between the two instructions accessing the 10-bit register, and the interrupt code
updates the TC1H register by accessing the same or any other of the 10-bit timer registers, then
the result of the access outside the interrupt will be corrupted. Therefore, when both the main
code and the interrupt code update the TC1H register, the main code must disable the interrupts
during the 16-bit access.
109
2588E–AVR–08/10
The following code examples show how to do an atomic read of the TCNT1 register contents.
Reading any of the OCR1A/B/C/D registers can be done by using the same principle.
Assembly Code Example
TIM1_ReadTCNT1:
; Save global interrupt flag
in r18,SREG
; Disable interrupts
cli
; Read TCNT1 into r17:r16
in r16,TCNT1
in r17,TC1H
; Restore global interrupt flag
out SREG,r18
ret
C Code Example
unsigned int TIM1_ReadTCNT1( void )
{
unsigned char sreg;
unsigned int i;
/* Save global interrupt flag */
sreg = SREG;
/* Disable interrupts */
_CLI();
/* Read TCNT1 into i */
i = TCNT1;
i |= ((unsigned int)TC1H << 8);
/* Restore global interrupt flag
SREG = sreg;
return i;
}
The assembly code example returns the TCNT1 value in the r17:r16 register pair.
110 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
The following code examples show how to do an atomic write of the TCNT1 register contents.
Writing any of the OCR1A/B/C/D registers can be done by using the same principle.
Assembly Code Example
TIM1_WriteTCNT1:
; Save global interrupt flag
in r18,SREG
; Disable interrupts
cli
; Set TCNT1 to r17:r16
out TC1H,r17
out TCNT1,r16
; Restore global interrupt flag
out SREG,r18
ret
C Code Example
void TIM1_WriteTCNT1( unsigned int i )
{
unsigned char sreg;
unsigned int i;
/* Save global interrupt flag */
sreg = SREG;
/* Disable interrupts */
_CLI();
/* Set TCNT1 to i */
TC1H = (i >> 8);
TCNT1 = (unsigned char)i;
/* Restore global interrupt flag */
SREG = sreg;
}
The assembly code example requires that the r17:r16 register pair contains the value to be writ-
ten to TCNT1.
111
2588E–AVR–08/10
12.12 Register Description
Table 12-9 shows the COM1A1:0 bit functionality when the PWM1A, WGM10 and WGM11 bits
are set to fast PWM mode.
112 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Table 12-10 shows the COM1A1:0 bit functionality when the PWM1A, WGM10 and WGM11 bits
are set to Phase and Frequency Correct PWM Mode.
Table 12-10. Compare Output Mode, Phase and Frequency Correct PWM Mode
COM1A1:0 OCW1A Behaviour OC1A Pin OC1A Pin
00 Normal port operation. Disconnected Disconnected
Cleared on Compare Match when up-counting.
01 Connected Connected
Set on Compare Match when down-counting.
Cleared on Compare Match when up-counting.
10 Connected Disconnected
Set on Compare Match when down-counting.
Set on Compare Match when up-counting.
11 Connected Disconnected
Cleared on Compare Match when down-counting.
Table 12-11 shows the COM1A1:0 bit functionality when the PWM1A, WGM10 and WGM11 bits
are set to single-slope PWM6 Mode. In the PWM6 Mode the same Waveform Output (OCW1A)
is used for generating all waveforms and the Output Compare values OC1A and OC1A are con-
nected on thw all OC1x and OC1x pins as described below.
Table 12-12 shows the COM1A1:0 bit functionality when the PWM1A, WGM10 and WGM11 bits
are set to dual-slope PWM6 Mode.I
Bits COM1A1 and COM1A0 are shadowed in TCCR1C. Writing to bits COM1A1 and COM1A0
will also change bits COM1A1S and COM1A0S in TCCR1C. Similary, changes written to bits
COM1A1S and COM1A0S in TCCR1C will show here. See “TCCR1C – Timer/Counter1 Control
Register C” on page 117.
113
2588E–AVR–08/10
• Bits 5,4 – COM1B1, COM1B0: Comparator B Output Mode, Bits 1 and 0
These bits control the behaviour of the Waveform Output (OCW1B) and the connection of the
Output Compare pin (OC1B). If one or both of the COM1B1:0 bits are set, the OC1B output
overrides the normal port functionality of the I/O pin it is connected to. The complementary
OC1B output is connected only in PWM modes when the COM1B1:0 bits are set to “01”. Note
that the Data Direction Register (DDR) bit corresponding to the OC1B pin must be set in order to
enable the output driver.
The function of the COM1B1:0 bits depends on the PWM1B and WGM11:10 bit settings. Table
12-13 shows the COM1B1:0 bit functionality when the PWM1B bit is set to Normal Mode (non-
PWM).
Table 12-14 shows the COM1B1:0 bit functionality when the PWM1B and WGM11:10 bits are
set to Fast PWM Mode.
Table 12-15 shows the COM1B1:0 bit functionality when the PWM1B and WGM11:10 bits are
set to Phase and Frequency Correct PWM Mode.
Table 12-15. Compare Output Mode, Phase and Frequency Correct PWM Mode
COM1B1:0 OCW1B Behaviour OC1B Pin OC1B Pin
00 Normal port operation. Disconnected Disconnected
Cleared on Compare Match when up-counting.
01 Connected Connected
Set on Compare Match when down-counting.
Cleared on Compare Match when up-counting.
10 Connected Disconnected
Set on Compare Match when down-counting.
Set on Compare Match when up-counting.
11 Connected Disconnected
Cleared on Compare Match when down-counting.
Bits COM1B1 and COM1B0 are shadowed in TCCR1C. Writing to bits COM1B1 and COM1B0
will also change bits COM1B1S and COM1B0S in TCCR1C. Similary, changes written to bits
114 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
COM1B1S and COM1B0S in TCCR1C will show here. See “TCCR1C – Timer/Counter1 Control
Register C” on page 117.
115
2588E–AVR–08/10
The dedicated Dead Time prescaler in front of the Dead Time Generator can divide the
Timer/Counter1 clock (PCK or CK) by 1, 2, 4 or 8 providing a large range of dead times that can
be generated. The Dead Time prescaler is controlled by two bits DTPS11 and DTPS10 from the
Dead Time Prescaler register. These bits define the division factor of the Dead Time prescaler.
The division factors are given in Table 12-16.
• Bits 3:0 – CS13, CS12, CS11, CS10: Clock Select Bits 3, 2, 1, and 0
The Clock Select bits 3, 2, 1, and 0 define the prescaling source of Timer/Counter1.
116 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
• Bits 7,6 – COM1A1S, COM1A0S: Comparator A Output Mode, Shadow Bits 1 and 0
These are shadow bits of COM1A1 and COM1A0 in TCCR1A. Writing to bits COM1A1S and
COM1A0S will also change bits COM1A1 and COM1A0 in TCCR1A. Similary, changes written
to bits COM1A1 and COM1A0 in TCCR1A will show here.
See “TCCR1A – Timer/Counter1 Control Register A” on page 112 for information on bit usage.
• Bits 5,4 – COM1B1S, COM1B0S: Comparator B Output Mode, Shadow Bits 1 and 0
These are shadow bits of COM1B1 and COM1B0 in TCCR1A. Writing to bits COM1B1S and
COM1B0S will also change bits COM1B1 and COM1B0 in TCCR1A. Similary, changes written
to bits COM1B1 and COM1B0 in TCCR1A will show here.
See “TCCR1A – Timer/Counter1 Control Register A” on page 112 for information on bit usage.
Table 12-19 shows the COM1D1:0 bit functionality when the PWM1D and WGM11:10 bits are
set to Fast PWM Mode.
117
2588E–AVR–08/10
Table 12-20 shows the COM1D1:0 bit functionality when the PWM1D and WGM11:10 bits are
set to Phase and Frequency Correct PWM Mode.
Table 12-20. Compare Output Mode, Phase and Frequency Correct PWM Mode
COM1D1:0 OCW1D Behaviour OC1D Pin OC1D Pin
00 Normal port operation. Disconnected Disconnected
Cleared on Compare Match when up-counting.
01 Connected Connected
Set on Compare Match when down-counting.
Cleared on Compare Match when up-counting.
10 Connected Disconnected
Set on Compare Match when down-counting.
Set on Compare Match when up-counting.
11 Connected Disconnected
Cleared on Compare Match when down-counting.
118 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
119
2588E–AVR–08/10
the Output Compare Override Enable Bit is cleared. Table 12-22 shows the Output Compare
Override Enable Bits and their corresponding Output Compare pins.
Table 12-22. Output Compare Override Enable Bits vs. Output Compare Pins
Output CompareOverride Enable Bit Output Compare Output Output Compare Pin
OC1OE0 OC1A PB0
OC1OE1 OC1A PB1
OC1OE2 OC1B PB2
OC1OE3 OC1B PB3
OC1OE4 OC1D PB4
OC1OE5 OC1D PB5
120 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
• Bits 1:0 – TC19, TC18: Two MSB bits of the 10-bit accesses
If 10-bit accuracy is used, the Timer/Counter1 High Byte Register (TC1H) is used for temporary
storing the MSB bits (TC19, TC18) of the 10-bit acceses. The same TC1H register is shared
between all 10-bit registers within the Timer/Counter1. Note that special procedures must be fol-
lowed when accessing the 10-bit TCNT1 register via the 8-bit AVR data bus. These procedures
are described in section “Accessing 10-Bit Registers” on page 108.
121
2588E–AVR–08/10
12.12.10 OCR1B – Timer/Counter1 Output Compare Register B
Bit 7 6 5 4 3 2 1 0
0x2C (0x4C) MSB LSB OCR1B
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial value 0 0 0 0 0 0 0 0
122 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Note that, if 10-bit accuracy is used special procedures must be followed when accessing the
internal 10-bit Output Compare Registers via the 8-bit AVR data bus. These procedures are
described in section “Accessing 10-Bit Registers” on page 108.
123
2588E–AVR–08/10
the corresponding interrupt handling vector. Alternatively, OCF1A is cleared, after synchroniza-
tion clock cycle, by writing a logic one to the flag. When the I-bit in SREG, OCIE1A, and OCF1A
are set (one), the Timer/Counter1 A compare match interrupt is executed.
124 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
13.1 Features
• Two-wire Synchronous Data Transfer (Master or Slave)
• Three-wire Synchronous Data Transfer (Master or Slave)
• Data Received Interrupt
• Wakeup from Idle Mode
• In Two-wire Mode: Wake-up from All Sleep Modes, Including Power-down Mode
• Two-wire Start Condition Detector with Interrupt Capability
13.2 Overview
The Universal Serial Interface, or USI, provides the basic hardware resources needed for serial
communication. Combined with a minimum of control software, the USI allows significantly
higher transfer rates and uses less code space than solutions based on software only. Interrupts
are included to minimize the processor load.
A simplified block diagram of the USI is shown in Figure 13-1 For actual placement of I/O pins
refer to “Pinout ATtiny261/461/861 and ATtiny261V/461V/861V” on page 2. Device-specific I/O
Register and bit locations are listed in the “Register Descriptions” on page 132.
3
2
USIDR
1 TIM0 COMP
0
USIDB
3 0
2 USCK/SCL (Input/Open Drain)
4-bit Counter 1
USIOIF
DATA BUS
USISIF
USIDC
USIPF
1
0 CLOCK
HOLD
[1]
Two-wire Clock
USISR Control Unit
2
USIWM1
USIWM0
USICS1
USICS0
USICLK
USIOIE
USISIE
USITC
USICR
The 8-bit USI Data Register (USIDR) is directly accessible via the data bus and contains the
incoming and outgoing data. The register has no buffering so the data must be read as quickly
as possible to ensure that no data is lost. The data register is a serial shift register where the
most significant bit is connected to one of two output pins depending of the wire mode configura-
tion. A transparent latch between the output of the data register and the output pin delays the
change of data output to the opposite clock edge of the data input sampling. The serial input is
always sampled from the Data Input (DI) pin, regardless of the configuration.
125
2588E–AVR–08/10
The 4-bit counter can be both read and written via the data bus, and it can generate an overflow
interrupt. The data register and the counter are clocked simultaneously by the same clock
source, allowing the counter to count the number of bits received or transmitted and generate an
interrupt when the transfer is complete. Note that when an external clock source is selected the
counter counts both clock edges. In this case the counter counts the number of edges, and not
the number of bits. The clock can be selected from three different sources: The USCK pin, the
Timer/Counter0 Compare Match or from software.
The Two-wire clock control unit can generate an interrupt when a start condition is detected on
the Two-wire bus. It can also generate wait states by holding the clock pin low after a start con-
dition is detected, or after the counter overflows.
DO
DI
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
USCK
SLAVE
DO
DI
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
USCK
PORTxn
MASTER
Figure 13-2 shows two USI units operating in three-wire mode, one as Master and one as Slave.
The two USI Data Register are interconnected in such way that after eight USCK clocks, the
data in each register are interchanged. The same clock also increments the USI’s 4-bit counter.
The Counter Overflow (interrupt) Flag, or USIOIF, can therefore be used to determine when a
transfer is completed. The clock is generated by the Master device software by toggling the
USCK pin via the PORT Register or by writing a one to the USITC bit in USICR.
126 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
USCK
USCK
DO MSB 6 5 4 3 2 1 LSB
DI MSB 6 5 4 3 2 1 LSB
A B C D E
The Three-wire mode timing is shown in Figure 13-3. At the top of the figure is a USCK cycle ref-
erence. One bit is shifted into the USI Data Register (USIDR) for each of these cycles. The
USCK timing is shown for both external clock modes. In External Clock mode 0 (USICS0 = 0), DI
is sampled at positive edges, and DO is changed (Data Register is shifted by one) at negative
edges. In external clock mode 1 (USICS0 = 1) the opposite edges with respect to mode 0 are
used. In other words, data is sampled at negative and output is changed at positive edges. The
USI clock modes corresponds to the SPI data mode 0 and 1.
Referring to the timing diagram (Figure 13-3), a bus transfer involves the following steps:
1. The slave and master devices set up their data outputs and, depending on the protocol
used, enable their output drivers (mark A and B). The output is set up by writing the
data to be transmitted to the USI Data Register. The output is enabled by setting the
corresponding bit in the Data Direction Register of Port A. Note that there is not a pre-
ferred order of points A and B in the figure, but both must be at least one half USCK
cycle before point C, where the data is sampled. This is in order to ensure that the data
setup requirement is satisfied. The 4-bit counter is reset to zero.
2. The master software generates a clock pulse by toggling the USCK line twice (C and
D). The bit values on the data input (DI) pins are sampled by the USI on the first edge
(C), and the data output is changed on the opposite edge (D). The 4-bit counter will
count both edges.
3. Step 2. is repeated eight times for a complete register (byte) transfer.
4. After eight clock pulses (i.e., 16 clock edges) the counter will overflow and indicate that
the transfer has been completed. The data bytes transferred must now be processed
before a new transfer can be initiated. The overflow interrupt will wake up the processor
if it is set to Idle mode. Depending on the protocol used the slave device can now set its
output to high impedance.
SPITransfer:
sts USIDR,r16
ldi r16,(1<<USIOIF)
sts USISR,r16
ldi r16,(1<<USIWM0)|(1<<USICS1)|(1<<USICLK)|(1<<USITC)
127
2588E–AVR–08/10
SPITransfer_loop:
sts USICR,r16
lds r16, USISR
sbrs r16, USIOIF
rjmp SPITransfer_loop
lds r16,USIDR
ret
The code is size optimized using only eight instructions (plus return). The code example
assumes that the DO and USCK pins have been enabled as outputs in DDRA. The value stored
in register r16 prior to the function is called is transferred to the slave device, and when the
transfer is completed the data received from the slave is stored back into the register r16.
The second and third instructions clear the USI Counter Overflow Flag and the USI counter
value. The fourth and fifth instructions set three-wire mode, positive edge clock, count at USITC
strobe, and toggle USCK. The loop is repeated 16 times.
The following code demonstrates how to use the USI as an SPI master with maximum speed
(fSCK = fCK/2):
SPITransfer_Fast:
out USIDR,r16
ldi r16,(1<<USIWM0)|(0<<USICS0)|(1<<USITC)
ldi r17,(1<<USIWM0)|(0<<USICS0)|(1<<USITC)|(1<<USICLK)
in r16,USIDR
ret
128 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
The code is size optimized using only eight instructions (+ ret). The code example assumes that
the DO is configured as output and USCK pin is configured as input in the DDR Register. The
value stored in register r16 prior to the function is called is transferred to the master device, and
when the transfer is completed the data received from the Master is stored back into the r16
Register.
Note that the first two instructions are for initialization, only, and need only be executed once.
These instructions set three-wire mode and positive edge clock. The loop is repeated until the
USI Counter Overflow Flag is set.
129
2588E–AVR–08/10
Figure 13-4. Two-wire Mode Operation, Simplified Diagram
VCC
SDA
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SCL
HOLD
SCL
Two-wire Clock
Control Unit
SLAVE
SDA
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SCL
PORTxn
MASTER
The data direction is not given by the physical layer. A protocol, like the one used by the TWI-
bus, must be implemented to control the data flow.
SDA
A B C D E F
Referring to the timing diagram (Figure 13-5), a bus transfer involves the following steps:
1. The start condition is generated by the master by forcing the SDA low line while keep-
ing the SCL line high (A). SDA can be forced low either by writing a zero to bit 7 of the
USI Data Register, or by setting the corresponding bit in the PORTA register to zero.
Note that the Data Direction Register bit must be set to one for the output to be
enabled. The start detector logic of the slave device (see Figure 13-6 on page 131)
detects the start condition and sets the USISIF Flag. The flag can generate an interrupt
if necessary.
2. In addition, the start detector will hold the SCL line low after the master has forced a
negative edge on this line (B). This allows the slave to wake up from sleep or complete
other tasks before setting up the USI Data Register to receive the address. This is done
by clearing the start condition flag and resetting the counter.
130 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
3. The master set the first bit to be transferred and releases the SCL line (C). The slave
samples the data and shifts it into the USI Data Register at the positive edge of the SCL
clock.
4. After eight bits containing slave address and data direction (read or write) have been
transferred, the slave counter overflows and the SCL line is forced low (D). If the slave
is not the one the master has addressed, it releases the SCL line and waits for a new
start condition.
5. When the slave is addressed, it holds the SDA line low during the acknowledgment
cycle before holding the SCL line low again (i.e., the USI Counter Register must be set
to 14 before releasing SCL at (D)). Depending on the R/W bit the master or slave
enables its output. If the bit is set, a master read operation is in progress (i.e., the slave
drives the SDA line) The slave can hold the SCL line low after the acknowledge (E).
6. Multiple bytes can now be transmitted, all in same direction, until a stop condition is
given by the master (F), or a new start condition is given.
If the slave is not able to receive more data it does not acknowledge the data byte it has last
received. When the master does a read operation it must terminate the operation by forcing the
acknowledge bit low after the last byte transmitted.
CLOCK
D Q D Q
HOLD
SDA
CLR CLR
SCL
Write( USISIF)
The start condition detector works asynchronously and can therefore wake up the processor
from power-down sleep mode. However, the protocol used might have restrictions on the SCL
hold time. Therefore, when using this feature in this case the Oscillator start-up time set by the
CKSEL Fuses (see “Clock System” on page 24) must also be taken into the consideration. Refer
to the USISIF bit description on page 133 for further details.
131
2588E–AVR–08/10
13.4 Alternative USI Usage
The flexible design of the USI allows it to be used for other tasks when serial communication is
not needed. Below are some examples.
132 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
The content of the Serial Register is loaded to the USI Buffer Register when the trasfer is com-
pleted, and instead of accessing the USI Data Register (the Serial Register) the USI Data Buffer
can be accessed when the CPU reads the received data. This gives the CPU time to handle
other program tasks too as the controlling of the USI is not so timing critical. The USI flags as set
same as when reading the USIDR register.
The Status Register contains Interrupt Flags, line Status Flags and the counter value.
133
2588E–AVR–08/10
The 4-bit counter increments by one for each clock generated either by the external clock edge
detector, by a Timer/Counter0 Compare Match, or by software using USICLK or USITC strobe
bits. The clock source depends of the setting of the USICS1:0 bits. For external clock operation
a special feature is added that allows the clock to be generated by writing to the USITC strobe
bit. This feature is enabled by write a one to the USICLK bit while setting an external clock
source (USICS1 = 1).
Note that even when no wire mode is selected (USIWM1:0 = 0) the external clock input
(USCK/SCL) are can still be used by the counter.
The Control Register includes interrupt enable control, wire mode setting, Clock Select setting,
and clock strobe.
134 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Note: 1. The DI and USCK pins are renamed to Serial Data (SDA) and Serial Clock (SCL) respectively
to avoid confusion between the modes of operation.
135
2588E–AVR–08/10
Table 13-2. Relations between the USICS1:0 and USICLK Setting (Continued)
USI Data Register Clock
USICS1 USICS0 USICLK Source 4-bit Counter Clock Source
1 1 0 External, negative edge External, both edges
1 0 1 External, positive edge Software clock strobe (USITC)
1 1 1 External, negative edge Software clock strobe (USITC)
136 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
ACBG
ACM2..1
AIN0
AIN1 MUX
AIN2
ACME
HSEL
HLEV
ADEN
ADC MULTIPLEXER
OUTPUT (1)
See Figure 1-1 on page 2 and Table 10-3 on page 63 for Analog Comparator pin placement.
137
2588E–AVR–08/10
Table 14-1. Analog Comparator Multiplexed Input (Continued)
ACME ADEN MUX5:0 ACM2:0 Positive Input Negative Input
0 x xxxxxx 100 AIN2 AIN0
0 x xxxxxx 101,110,111 AIN2 AIN1
1 1 xxxxxx 000 AIN0 AIN1
1 0 000000 000 AIN0 ADC0
1 0 000000 01x AIN1 ADC0
1 0 000000 1xx AIN2 ADC0
1 0 000001 000 AIN0 ADC1
1 0 000001 01x AIN1 ADC1
1 0 000001 1xx AIN2 ADC1
1 0 000010 000 AIN0 ADC2
1 0 000010 01x AIN1 ADC2
1 0 000010 1xx AIN2 ADC2
1 0 000011 000 AIN0 ADC3
1 0 000011 01x AIN1 ADC3
1 0 000011 1xx AIN2 ADC3
1 0 000100 000 AIN0 ADC4
1 0 000100 01x AIN1 ADC4
1 0 000100 1xx AIN2 ADC4
1 0 000101 000 AIN0 ADC5
1 0 000101 01x AIN1 ADC5
1 0 000101 1xx AIN2 ADC5
1 0 000110 000 AIN0 ADC6
1 0 000110 01x AIN1 ADC6
1 0 000110 1xx AIN2 ADC6
1 0 000111 000 AIN0 ADC7
1 0 000111 01x AIN1 ADC7
1 0 000111 1xx AIN2 ADC7
1 0 001000 000 AIN0 ADC8
1 0 001000 01x AIN1 ADC8
1 0 001000 1xx AIN2 ADC8
1 0 001001 000 AIN0 ADC9
1 0 001001 01x AIN1 ADC9
1 0 001001 1xx AIN2 ADC9
1 0 001010 000 AIN0 ADC10
1 0 001010 01x AIN1 ADC10
1 0 001010 1xx AIN2 ADC10
138 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
139
2588E–AVR–08/10
• Bits 1, 0 – ACIS1, ACIS0: Analog Comparator Interrupt Mode Select
These bits determine which comparator events that trigger the Analog Comparator interrupt. The
different settings are shown in Table 14-2.
When changing the ACIS1/ACIS0 bits, the Analog Comparator Interrupt must be disabled by
clearing its Interrupt Enable bit in the ACSR Register. Otherwise an interrupt can occur when the
bits are changed.
140 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
applied to the AREF pin and the digital input from this pin is not needed, this bit should be written
logic one to reduce power consumption in the digital input buffer.
141
2588E–AVR–08/10
15. ADC – Analog to Digital Converter
15.1 Features
• 10-bit Resolution
• 1.0 LSB Integral Non-linearity
• ± 2 LSB Absolute Accuracy
• 13µs Conversion Time
• 15 kSPS at Maximum Resolution
• 11 Multiplexed Single Ended Input Channels
• 16 Differential input pairs
• 15 Differential input pairs with selectable gain
• Temperature Sensor Input Channel
• Optional Left Adjustment for ADC Result Readout
• 0 - VCC ADC Input Voltage Range
• Selectable 1.1V / 2.56V ADC Voltage Reference
• Free Running or Single Conversion Mode
• ADC Start Conversion by Auto Triggering on Interrupt Sources
• Interrupt on ADC Conversion Complete
• Sleep Mode Noise Cancele
• Unipolar / Bipolar Input Mode
• Input Polarity Reversal Mode
15.2 Overview
The ATtiny261/461/861 features a 10-bit successive approximation ADC. The ADC is connected
to a 11-channel Analog Multiplexer which allows 16 differential voltage input combinations and
11 single-ended voltage inputs constructed from the pins PA7:PA0 or PB7:PB4. The differential
input is equipped with a programmable gain stage, providing amplification steps of 1x, 8x, 20x or
32x on the differential input voltage before the A/D conversion. The single-ended voltage inputs
refer to 0V (GND).
The ADC contains a Sample and Hold circuit which ensures that the input voltage to the ADC is
held at a constant level during conversion. A block diagram of the ADC is shown in Figure 15-1
on page 143.
Internal reference voltages of nominally 1.1V or 2.56V are provided On-chip. The Internal refer-
ance voltage of 2.56V, can optionally be externally decoupled at the AREF (PA3) pin by a
capacitor, for better noise performance. Alternatively, VCC can be used as reference voltage for
single ended channels. There is also an option to use an external voltage reference and turn-off
the internal voltage reference. These options are selected using the REFS2:0 bits of the ADC-
SRB and ADMUX registers.
142 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
ADIE
ADIF
15 0
ADC CTRL. & STATUS ADC MULTIPLEXER ADC CTRL. & STATUS ADC DATA REGISTER
REGISTER B (ADCSRB) SELECT (ADMUX) REGISTER A (ADCSRA) (ADCH/ADCL)
MUX4
MUX3
MUX2
MUX1
MUX0
MUX5
ADLAR
REFS2
REFS1
REFS0
ADPS2
ADPS1
ADPS0
ADATE
GSEL
ADEN
ADSC
ADIF
ADC[9:0]
PRESCALER
MUX DECODER
CONVERSION LOGIC
VCC
GAIN SELECTION
CHANNEL SELECTION
AREF
SAMPLE & HOLD
COMPARATOR
INTERNAL 2.56/1.1V
REFERENCE 10-BIT DAC -
+
INTERNAL 1.1V
REFERENCE
AGND
TEMPERATURE
SENSOR
ADC10
SINGLE ENDED /
ADC9
DIFFERENTIAL SELECTION
ADC8
ADC7 POS.
INPUT
MUX ADC
ADC6 MULTIPLEXER OUTPUT
ADC5
ADC4
ADC3
ADC2 MUX
+
ADC1 -
GAIN
ADC0 AMPLIFIER
NEG.
INPUT
MUX
15.3 Operation
The ADC converts an analog input voltage to a 10-bit digital value through successive approxi-
mation. The minimum value represents GND and the maximum value represents the voltage on
VCC, the voltage on the AREF pin or an internal 1.1V / 2.56V voltage reference.
The voltage reference for the ADC may be selected by writing to the REFS2:0 bits in ADCSRB
and ADMUX registers. The VCC supply, the AREF pin or an internal 1.1V / 2.56V voltage refer-
ence may be selected as the ADC voltage reference. Optionally the internal 1.1V / 2.56V voltage
143
2588E–AVR–08/10
reference may be decoupled by an external capacitor at the AREF pin to improve noise
immunity.
The analog input channel and differential gain are selected by writing to the MUX5:0 bits in
ADMUX. Any of the 11 ADC input pins ADC10:0 can be selected as single ended inputs to the
ADC. The positive and negative inputs to the differential gain amplifier are described in Table
15-4.
If differential channels are selected, the differential gain stage amplifies the voltage difference
between the selected input pair by the selected gain factor, 1x, 8x, 20x or 32x, according to the
setting of the MUX5:0 bits in ADMUX and the GSEL bit in ADCSRB. This amplified value then
becomes the analog input to the ADC. If single ended channels are used, the gain amplifier is
bypassed altogether.
If the same ADC input pin is selected as both the positive and negative input to the differential
gain amplifier, the remaining offset in the gain stage and conversion circuitry can be measured
directly as the result of the conversion. This figure can be subtracted from subsequent conver-
sions with the same gain setting to reduce offset error to below 1 LSW.
The on-chip temperature sensor is selected by writing the code “111111” to the MUX5:0 bits in
ADMUX register when the ADC11 channel is used as an ADC input.
The ADC is enabled by setting the ADC Enable bit, ADEN in ADCSRA. Voltage reference and
input channel selections will not go into effect until ADEN is set. The ADC does not consume
power when ADEN is cleared, so it is recommended to switch off the ADC before entering power
saving sleep modes.
The ADC generates a 10-bit result which is presented in the ADC Data Registers, ADCH and
ADCL. By default, the result is presented right adjusted, but can optionally be presented left
adjusted by setting the ADLAR bit in ADMUX.
If the result is left adjusted and no more than 8-bit precision is required, it is sufficient to read
ADCH. Otherwise, ADCL must be read first, then ADCH, to ensure that the content of the data
registers belongs to the same conversion. Once ADCL is read, ADC access to data registers is
blocked. This means that if ADCL has been read, and a conversion completes before ADCH is
read, neither register is updated and the result from the conversion is lost. When ADCH is read,
ADC access to the ADCH and ADCL Registers is re-enabled.
The ADC has its own interrupt which can be triggered when a conversion completes. When ADC
access to the data registers is prohibited between reading of ADCH and ADCL, the interrupt will
trigger even if the result is lost.
144 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
conversion will not be started. If another positive edge occurs on the trigger signal during con-
version, the edge will be ignored. Note that an Interrupt Flag will be set even if the specific
interrupt is disabled or the Global Interrupt Enable bit in SREG is cleared. A conversion can thus
be triggered without causing an interrupt. However, the Interrupt Flag must be cleared in order to
trigger a new conversion at the next interrupt event.
ADTS[2:0]
PRESCALER
START CLKADC
ADIF ADATE
SOURCE 1
. CONVERSION
. LOGIC
.
. EDGE
SOURCE n DETECTOR
ADSC
Using the ADC Interrupt Flag as a trigger source makes the ADC start a new conversion as soon
as the ongoing conversion has finished. The ADC then operates in Free Running mode, con-
stantly sampling and updating the ADC Data Register. The first conversion must be started by
writing a logical one to the ADSC bit in ADCSRA. In this mode the ADC will perform successive
conversions independently of whether the ADC Interrupt Flag, ADIF is cleared or not.
If Auto Triggering is enabled, single conversions can be started by writing ADSC in ADCSRA to
one. ADSC can also be used to determine if a conversion is in progress. The ADSC bit will be
read as one during a conversion, independently of how the conversion was started.
145
2588E–AVR–08/10
Figure 15-3. ADC Prescaler
ADEN
START Reset
7-BIT ADC PRESCALER
CK
CK/128
CK/64
CK/32
CK/16
CK/2
CK/4
CK/8
ADPS0
ADPS1
ADPS2
When initiating a single ended conversion by setting the ADSC bit in ADCSRA, the conversion
starts at the following rising edge of the ADC clock cycle.
A normal conversion takes 13 ADC clock cycles. The first conversion after the ADC is switched
on (ADEN in ADCSRA is set) takes 25 ADC clock cycles in order to initialize the analog circuitry,
as shown in Figure 15-4 below.
Figure 15-4. ADC Timing Diagram, First Conversion (Single Conversion Mode)
Next
First Conversion Conversion
Cycle Number 1 2 12 13 14 15 16 17 18 19 20 21 22 23 24 25 1 2 3
ADC Clock
ADEN
ADSC
ADIF
The actual sample-and-hold takes place 1.5 ADC clock cycles after the start of a normal conver-
sion and 13.5 ADC clock cycles after the start of an first conversion. See Figure 15-5. When a
conversion is complete, the result is written to the ADC Data Registers, and ADIF is set. In Sin-
gle Conversion mode, ADSC is cleared simultaneously. The software may then set ADSC again,
and a new conversion will be initiated on the first rising ADC clock edge.
146 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Cycle Number 1 2 3 4 5 6 7 8 9 10 11 12 13 1 2 3
ADC Clock
ADSC
ADIF
When Auto Triggering is used, the prescaler is reset when the trigger event occurs. See Figure
15-6. This assures a fixed delay from the trigger event to the start of conversion. In this mode,
the sample-and-hold takes place two ADC clock cycles after the rising edge on the trigger
source signal. Three additional CPU clock cycles are used for synchronization logic.
Cycle Number 1 2 3 4 5 6 7 8 9 10 11 12 13 1 2
ADC Clock
Trigger
Source
ADATE
ADIF
In Free Running mode (see Figure 15-7), a new conversion will be started immediately after the
conversion completes, while ADSC remains high.
147
2588E–AVR–08/10
Figure 15-7. ADC Timing Diagram, Free Running Conversion
One Conversion Next Conversion
11 12 13 1 2 3 4
Cycle Number
ADC Clock
ADSC
ADIF
148 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
When updating ADMUX in one of these conditions, the new settings will affect the next ADC
conversion.
Note that the ADC will not automatically be turned off when entering other sleep modes than Idle
mode and ADC Noise Reduction mode. The user is advised to write zero to ADEN before enter-
ing such sleep modes to avoid excessive power consumption.
149
2588E–AVR–08/10
15.8 Analog Input Circuitry
The analog input circuitry for single ended channels is illustrated in Figure 15-8 An analog
source applied to ADCn is subjected to the pin capacitance and input leakage of that pin, regard-
less of whether that channel is selected as input for the ADC. When the channel is selected, the
source must drive the S/H capacitor through the series resistance (combined resistance in the
input path).
IIH
ADCn
1..100 kΩ
CS/H= 14 pF
IIL
VCC/2
The capacitor in Figure 15-8 depicts the total capacitance, including the sample/hold capacitor
and any stray or parasitic capacitance inside the device. The value given is worst case.
The ADC is optimized for analog signals with an output impedance of approximately 10 kΩ or
less. If such a source is used, the sampling time will be negligible. If a source with higher imped-
ance is used, the sampling time will depend on how long time the source needs to charge the
S/H capacitor, with can vary widely. The user is recommended to only use low impedant sources
with slowly varying signals, since this minimizes the required charge transfer to the S/H
capacitor.
Signal components higher than the Nyquist frequency (fADC/2) should not be present to avoid
distortion from unpredictable signal convolution. The user is advised to remove high frequency
components with a low-pass filter before applying the signals as inputs to the ADC.
Where high ADC accuracy is required it is recommended to use ADC Noise Reduction Mode, as
described in Section 15.7 on page 149. This is especially the case when system clock frequency
is above 1 MHz, or when the ADC is used for reading the internal temperature sensor, as
150 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
described in Section 15.12 on page 154. A good system design with properly placed, external
bypass capacitors does reduce the need for using ADC Noise Reduction Mode
• Offset: The deviation of the first transition (0x000 to 0x001) compared to the ideal transition
(at 0.5 LSB). Ideal value: 0 LSB.
Ideal ADC
Actual ADC
Offset
Error
VREF Input Voltage
151
2588E–AVR–08/10
• Gain Error: After adjusting for offset, the Gain Error is found as the deviation of the last
transition (0x3FE to 0x3FF) compared to the ideal transition (at 1.5 LSB below maximum).
Ideal value: 0 LSB
Ideal ADC
Actual ADC
• Integral Non-linearity (INL): After adjusting for offset and gain error, the INL is the maximum
deviation of an actual transition compared to an ideal transition for any code. Ideal value: 0
LSB.
Ideal ADC
Actual ADC
152 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
• Differential Non-linearity (DNL): The maximum deviation of the actual code width (the interval
between two adjacent transitions) from the ideal code width (1 LSB). Ideal value: 0 LSB.
1 LSB
DNL
0x000
• Quantization Error: Due to the quantization of the input voltage into a finite number of codes,
a range of input voltages (1 LSB wide) will code to the same value. Always ± 0.5 LSB.
V IN ⋅ 1024
ADC = --------------------------
V REF
where VIN is the voltage on the selected input pin and VREF the selected voltage reference (see
Table 15-3 on page 155 and Table 15-4 on page 157). 0x000 represents analog ground, and
153
2588E–AVR–08/10
0x3FF represents the selected voltage reference minus one LSB. The result is presented in one-
sided form, from 0x3FF to 0x000.
where VPOS is the voltage on the positive input pin, VNEG the voltage on the negative input pin,
and VREF the selected voltage reference (see Table 15-3 on page 155 and Table 15-4 on page
157). The voltage on the positive pin must always be larger than the voltage on the negative pin
or otherwise the voltage difference is saturated to zero. The result is presented in one-sided
form, from 0x000 (0d) to 0x3FF (+1023d). The GAIN is either 1x, 8x, 20x or 32x.
where VPOS is the voltage on the positive input pin, VNEG the voltage on the negative input pin,
and VREF the selected voltage reference. The result is presented in two’s complement form, from
0x200 (-512d) through 0x000 (+0d) to 0x1FF (+511d). The GAIN is either 1x, 8x, 20x or 32x.
However, if the signal is not bipolar by nature (9 bits + sign as the 10th bit), this scheme loses
one bit of the converter dynamic range. Then, if the user wants to perform the conversion with
the maximum dynamic range, the user can perform a quick polarity check of the result and use
the unipolar differential conversion with selectable differential input pair. When the polarity check
is performed, it is sufficient to read the MSB of the result (ADC9 in ADCH). If the bit is one, the
result is negative, and if this bit is zero, the result is positive.
154 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
assuming calibration at room temperature. Better accuracies are achieved by using two
temperature points for calibration.
The values described in Table 15-2 are typical values. However, due to process variation the
temperature sensor output voltage varies from one chip to another. To be capable of achieving
more accurate results the temperature measurement can be calibrated in the application soft-
ware. The sofware calibration can be done using the formula:
T = k * [(ADCH << 8) | ADCL] + TOS
where ADCH and ADCL are the ADC data registers, k is the fixed slope coefficient and TOS is
the temperature sensor offset. Typically, k is very close to 1.0 and in single-point calibration the
coefficient may be omitted. Where higher accuracy is required the slope coefficient should be
evaluated based on measurements at two temperatures.
If these bits are changed during a conversion, the change will not go in effect until this conver-
sion is complete (ADIF in ADCSR is set). Also note, that when these bits are changed, the next
conversion will take 25 ADC clock cycles.
155
2588E–AVR–08/10
Special care should be taken when changing differential channels. Once a differential channel
has been selected the input stage may take a while to stabilize. It is therefore recommended to
force the ADC to perform a long conversion when changing multiplexer or voltage reference set-
tings. This can be done by first turning off the ADC, then changing reference settings and then
turn on the ADC. Alternatively, the first conversion results after changing reference settings
should be discarded.
It is not recommended to use an external AREF higher than (VCC - 1V) for channels with differ-
ential gain, as this will affect ADC accuracy.
Internal voltage reference options may not be used if an external voltage is being applied to the
AREF pin.
156 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
gain stage enables offset measurements. Selecting the single-ended channel ADC11 enables
the temperature sensor. Refer to Table 15-4 for details.
157
2588E–AVR–08/10
Table 15-4. Input Channel Selections (Continued)
Differential Input
Single-Ended
MUX5:0 Input Positive Negative Gain
100000 ADC0(PA0) ADC1(PA1) 20x/32x
100001 ADC0(PA0) ADC1(PA1) 1x/8x
N/A
100010 ADC1(PA1 ADC0(PA0) 20x/32x
100011 ADC1(PA1) ADC0(PA0) 1x/8x
100100 ADC1(PA1) ADC2(PA2) 20x/32x
100101 ADC1(PA1) ADC2(PA2) 1x/8x
N/A
100110 ADC2(PA2 ADC1(PA1) 20x/32x
100111 ADC2(PA2) ADC1(PA1) 1x/8x
101000 ADC2(PA2) ADC0(PA0) 20x/32x
101001 ADC2(PA2) ADC0(PA0) 1x/8x
N/A
101010 ADC0(PA0) ADC2(PA2) 20x/32x
101011 ADC0(PA0) ADC2(PA2) 1x/8x
101100 ADC4(PA5) ADC5(PA6) 20x/32x
101101 ADC4(PA5) ADC5(PA6) 1x/8x
N/A
101110 ADC5(PA6) ADC4(PA5) 20x/32x
101111 ADC5(PA6) ADC4(PA5) 1x/8x
110000 ADC5(PA6) ADC6(PA7) 20x/32x
110001 ADC5(PA6) ADC6(PA7) 1x/8x
N/A
110010 ADC6(PA7) ADC5(PA6) 20x/32x
110011 ADC6(PA7) ADC5(PA6) 1x/8x
110100 ADC6(PA7) ADC4(PA5) 20x/32x
110101 ADC6(PA7) ADC4(PA5) 1x/8x
N/A
110110 ADC4(PA5) ADC6(PA7) 20x/32x
110111 ADC4(PA5) ADC6(PA7) 1x/8x
111000 ADC0(PA0) ADC0(PA0) 20x/32x
111001 ADC0(PA0) ADC0(PA0) 1x/8x
N/A
111010 ADC1(PA1) ADC1(PA1) 20x/32x
111011 ADC2(PA2) ADC2(PA2) 20x/32x
111100 ADC4(PA5) ADC4(PA5) 20x/32x
111101 N/A ADC5(PA6) ADC5(PA6) 20x/32x
111110 ADC6(PA7) ADC6(PA7) 20x/32x
(1)
111111 ADC11 N/A N/A N/A
158 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
If these bits are changed during a conversion, the change will not go into effect until this conver-
sion is complete (ADIF in ADCSRA is set).
159
2588E–AVR–08/10
Table 15-5. ADC Prescaler Selections (Continued)
ADPS2 ADPS1 ADPS0 Division Factor
0 1 1 8
1 0 0 16
1 0 1 32
1 1 0 64
1 1 1 128
15.13.3.1 ADLAR = 0
Bit 15 14 13 12 11 10 9 8
0x05 (0x25) – – – – – – ADC9 ADC8 ADCH
0x04 (0x24) ADC7 ADC6 ADC5 ADC4 ADC3 ADC2 ADC1 ADC0 ADCL
7 6 5 4 3 2 1 0
Read/Write R R R R R R R R
R R R R R R R R
Initial Value 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
15.13.3.2 ADLAR = 1
Bit 15 14 13 12 11 10 9 8
0x05 (0x25) ADC9 ADC8 ADC7 ADC6 ADC5 ADC4 ADC3 ADC2 ADCH
0x04 (0x24) ADC1 ADC0 – – – – – – ADCL
7 6 5 4 3 2 1 0
Read/Write R R R R R R R R
R R R R R R R R
Initial Value 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
When an ADC conversion is complete, the result is found in these two registers.
When ADCL is read, the ADC Data Register is not updated until ADCH is read. Consequently, if
the result is left adjusted and no more than 8-bit precision is required, it is sufficient to read
ADCH. Otherwise, ADCL must be read first, then ADCH.
The ADLAR bit in ADMUX, and the MUXn bits in ADMUX affect the way the result is read from
the registers. If ADLAR is set, the result is left adjusted. If ADLAR is cleared (default), the result
is right adjusted.
160 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
161
2588E–AVR–08/10
Table 15-6. ADC Auto Trigger Source Selections
ADTS2 ADTS1 ADTS0 Trigger Source
1 0 1 Timer/Counter0 Compare Match B
1 1 0 Timer/Counter1 Overflow
1 1 1 Watchdog Interrupt Request
162 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
16.1 Features
• Complete Program Flow Control
• Emulates All On-chip Functions, Both Digital and Analog , except RESET Pin
• Real-time Operation
• Symbolic Debugging Support (Both at C and Assembler Source Level, or for Other HLLs)
• Unlimited Number of Program Break Points (Using Software Break Points)
• Non-intrusive Operation
• Electrical Characteristics Identical to Real Device
• Automatic Configuration System
• High-Speed Operation
• Programming of Non-volatile Memories
16.2 Overview
The debugWIRE On-chip debug system uses a One-wire, bi-directional interface to control the
program flow, execute AVR instructions in the CPU and to program the different non-volatile
memories.
VCC
dW dW(RESET)
GND
163
2588E–AVR–08/10
When designing a system where debugWIRE will be used, the following must be observed:
• Pull-Up resistor on the dW/(RESET) line must be in the range of 10k to 20 kΩ. However, the
pull-up resistor is optional.
• Connecting the RESET pin directly to VCC will not work.
• Capacitors inserted on the RESET pin must be disconnected when using debugWire.
• All external reset sources must be disconnected.
The DWDR Register provides a communication channel from the running program in the MCU
to the debugger. This register is only accessible by the debugWIRE and can therefore not be
used as a general purpose register in the normal operations.
164 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
If only a part of the page needs to be changed, the rest of the page must be stored (for example
in the temporary page buffer) before the erase, and then be re-written. When using alternative 1,
the Boot Loader provides an effective Read-Modify-Write feature which allows the user software
to first read the page, do the necessary changes, and then write back the modified data. If alter-
native 2 is used, it is not possible to read the old data while loading since the page is already
erased. The temporary page buffer can be accessed in a random sequence. It is essential that
the page address used in both the Page Erase and Page Write operation is addressing the
same page.
165
2588E–AVR–08/10
If the EEPROM is written in the middle of an SPM Page Load operation, all data loaded will be
lost.
Since the Flash is organized in pages (see Table 18-7 on page 173), the Program Counter can
be treated as having two different sections. One section, consisting of the least significant bits, is
addressing the words within a page, while the most significant bits are addressing the pages.
This is shown in Figure 17-1. Note that the Page Erase and Page Write operations are
addressed independently. Therefore it is of major importance that the software addresses the
same page in both the Page Erase and Page Write operation.
The LPM instruction uses the Z-pointer to store the address. Since this instruction addresses the
Flash byte-by-byte, also the LSB (bit Z0) of the Z-pointer is used.
PCMSB PAGEMSB
PROGRAM
PCPAGE PCWORD
COUNTER
01
02
PAGEEND
Note: The different variables used in Figure 17-1 are listed in Table 18-7 on page 173.
166 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
See section “Program And Data Memory Lock Bits” on page 170 for more information.
Refer to Table 18-5 on page 172 for a detailed description and mapping of the Fuse Low Byte.
167
2588E–AVR–08/10
To read the Fuse High Byte (FHB), simply replace the address in the Z-pointer with 0x0003 and
repeat the procedure above. If successful, the contents of the destination register are as follows.
Bit 7 6 5 4 3 2 1 0
Rd FHB7 FHB6 FHB5 FHB4 FHB3 FHB2 FHB1 FHB0
Refer to Table 18-4 on page 171 for detailed description and mapping of the Fuse High Byte.
To read the Fuse Extended Byte (FEB), replace the address in the Z-pointer with 0x0002 and
repeat the previous procedure. If successful, the contents of the destination register are as
follows.
Bit 7 6 5 4 3 2 1 0
Rd FEB7 FEB6 FEB5 FEB4 FEB3 FEB2 FEB1 FEB0
Refer to Table 18-3 on page 171 for detailed description and mapping of the Fuse Extended
Byte.
168 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
169
2588E–AVR–08/10
18. Memory Programming
This section describes the different methods for programming ATtiny261/461/861 memories.
Lock bits can also be read by device firmware. See section “Reading Fuse and Lock Bits from
Software” on page 167.
170 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Notes: 1. Enables SPM instruction. See “Self-Programming the Flash” on page 165.
171
2588E–AVR–08/10
Table 18-5. Fuse Low Byte
Fuse Low Byte Bit No Description Default Value
(1)
CKDIV8 7 Divide clock by 8 0 (programmed)
CKOUT (2) 6 Clock Output Enable 1 (unprogrammed)
SUT1 5 Select start-up time 1 (unprogrammed) (3)
SUT0 4 Select start-up time 0 (programmed) (3)
CKSEL3 3 Select Clock source 0 (programmed) (4)
CKSEL2 2 Select Clock source 0 (programmed) (4)
CKSEL1 1 Select Clock source 1 (unprogrammed) (4)
CKSEL0 0 Select Clock source 0 (programmed) (4)
Note that fuse bits are locked if Lock Bit 1 (LB1) is programmed. Fuse bits should be pro-
grammed before lock bits. The status of fuse bits is not affected by chip erase.
Fuse bits can also be read by device firmware. See section “Reading Fuse and Lock Bits from
Software” on page 167.
172 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Table 18-7. No. of Words in a Page and No. of Pages in the Flash
Device Flash Size Page Size PCWORD No. of Pages PCPAGE PCMSB
ATtiny261 1K words (2K bytes) 16 words PC[3:0] 64 PC[9:4] 9
ATtiny461 2K words (4K bytes) 32 words PC[4:0] 64 PC[10:5] 10
ATtiny861 4K words (8K bytes) 32 words PC[4:0] 128 PC[11:5] 11
Table 18-8. No. of Words in a Page and No. of Pages in the EEPROM
EEPROM
Device Size Page Size PCWORD No. of Pages PCPAGE EEAMSB
ATtiny261 128 bytes 4 bytes EEA[1:0] 32 EEA[6:2] 6
ATtiny461 256 bytes 4 bytes EEA[1:0] 64 EEA[7:2] 7
ATtiny861 512 bytes 4 bytes EEA[1:0] 128 EEA[8:2] 8
VCC
MOSI
MISO
SCK
RESET
GND
Note: If the device is clocked by the internal Oscillator, there is no need to connect a clock source to the
CLKI pin.
173
2588E–AVR–08/10
After RESET is set low, the Programming Enable instruction needs to be executed first before
program/erase operations can be executed.
Note: In Table 18-9, above, the pin mapping for SPI programming is listed. Not all parts use the SPI pins
dedicated for the internal SPI interface.
When programming the EEPROM, an auto-erase cycle is built into the self-timed programming
operation (in the Serial mode ONLY) and there is no need to first execute the Chip Erase
instruction. The Chip Erase operation turns the content of every memory location in both the
Program and EEPROM arrays into 0xFF.
Depending on CKSEL Fuses, a valid clock must be present. The minimum low and high periods
for the serial clock (SCK) input are defined as follows:
• Low:> 2 CPU clock cycles for fck < 12 MHz, 3 CPU clock cycles for fck >= 12 MHz
• High:> 2 CPU clock cycles for fck < 12 MHz, 3 CPU clock cycles for fck >= 12 MHz
174 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
interface before the Flash write operation completes can result in incorrect
programming.
5. A: The EEPROM array is programmed one byte at a time by supplying the address and
data together with the appropriate Write instruction. An EEPROM memory location is
first automatically erased before new data is written. If polling (RDY/BSY) is not used,
the user must wait at least tWD_EEPROM before issuing the next byte. (See Table 18-10.)
In a chip erased device, no 0xFFs in the data file(s) need to be programmed.
B: The EEPROM array is programmed one page at a time. The Memory page is loaded
one byte at a time by supplying the 2 LSB of the address and data together with the
Load EEPROM Memory Page instruction. The EEPROM Memory Page is stored by
loading the Write EEPROM Memory Page Instruction with the 6 MSB of the address.
When using EEPROM page access only byte locations loaded with the Load EEPROM
Memory Page instruction is altered. The remaining locations remain unchanged. If poll-
ing (RDY/BSY) is not used, the used must wait at least tWD_EEPROM before issuing the
next page (See Table 18-8). In a chip erased device, no 0xFF in the data file(s) need to
be programmed.
6. Any memory location can be verified by using the Read instruction which returns the
content at the selected address at serial output MISO.
7. At the end of the programming session, RESET can be set high to commence normal
operation.
8. Power-off sequence (if needed):
Set RESET to “1”.
Turn VCC power off.
Table 18-10. Minimum Wait Delay Before Writing the Next Flash or EEPROM Location
Symbol Minimum Wait Delay
tWD_FLASH 4.5 ms
tWD_EEPROM 4.0 ms
tWD_ERASE 9.0 ms
tWD_FUSE 4.5 ms
The instruction set is described in Table 18-11 on page 176 and Figure 18-2 on page 177.
175
2588E–AVR–08/10
Table 18-11. Serial Programming Instruction Set
Instruction Format
Instruction/Operation Byte 1 Byte 2 Byte 3 Byte4
Programming Enable $AC $53 $00 $00
Chip Erase (Program Memory/EEPROM) $AC $80 $00 $00
Poll RDY/BSY $F0 $00 $00 data byte out
Load Instructions
Load Extended Address byte(1) $4D $00 Extended adr $00
Load Program Memory Page, High byte $48 adr MSB adr LSB high data byte in
Load Program Memory Page, Low byte $40 adr MSB adr LSB low data byte in
Load EEPROM Memory Page (page access) $C1 $00 0000 000aa data byte in
Read Instructions
Read Program Memory, High byte $28 adr MSB adr LSB high data byte out
Read Program Memory, Low byte $20 adr MSB adr LSB low data byte out
Read EEPROM Memory $A0 $00 00aa aaaa data byte out
Read Lock bits $58 $00 $00 data byte out
Read Signature Byte $30 $00 0000 000aa data byte out
Read Fuse bits $50 $00 $00 data byte out
Read Fuse High bits $58 $08 $00 data byte out
Read Extended Fuse Bits $50 $08 $00 data byte out
Read Calibration Byte $38 $00 $00 data byte out
(6)
Write Instructions
Write Program Memory Page $4C adr MSB adr LSB $00
Write EEPROM Memory $C0 $00 00aa aaaa data byte in
Write EEPROM Memory Page (page access) $C2 $00 00aa aa00 $00
Write Lock bits $AC $E0 $00 data byte in
Write Fuse bits $AC $A0 $00 data byte in
Write Fuse High bits $AC $A8 $00 data byte in
Write Extended Fuse Bits $AC $A4 $00 data byte in
Notes: 1. Not all instructions are applicable for all parts.
2. a = address
3. Bits are programmed ‘0’, unprogrammed ‘1’.
4. To ensure future compatibility, unused Fuses and Lock bits should be unprogrammed (‘1’) .
5. Refer to the correspondig section for Fuse and Lock bits, Calibration and Signature bytes and Page size.
6. Instructions accessing program memory use a word address. This address may be random within the page range.
7. See http://www.atmel.com/avr for Application Notes regarding programming and programmers.
176 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Page Buffer
Page Offset
Page 0
Page 1
Page 2
Page Number
Page N-1
Program Memory/
EEPROM Memory
If the LSB in RDY/BSY data byte out is ‘1’, a programming operation is still pending. Wait until
this bit returns ‘0’ before the next instruction is carried out.
Within the same page, the low data byte must be loaded prior to the high data byte.
After data is loaded to the page buffer, program the EEPROM page, see Figure 18-2 on page
177.
177
2588E–AVR–08/10
Figure 18-3. Parallel Programming.
+5V
WR PB0 VCC
AVCC
XA1/BS2 PB2
XTAL1/PB4
OE PB5
RDY/BSY PB6
+12 V RESET
GND
178 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
The XA1/XA0 pins determine the action executed when the XTAL1 pin is given a positive pulse.
The bit coding is shown in Table 18-14.
When pulsing WR or OE, the command loaded determines the action executed. The different
Commands are shown in Table 18-15.
179
2588E–AVR–08/10
18.7.3 Considerations for Efficient Programming
The loaded command and address are retained in the device during programming. For efficient
programming, the following should be considered:
• The command needs only be loaded once when writing or reading multiple memory
locations.
• Skip writing the data value 0xFF, that is the contents of the entire EEPROM (unless the
EESAVE Fuse is programmed) and Flash after a Chip Erase.
• Address high byte needs only be loaded before programming or reading a new 256 word
window in Flash or 256 byte EEPROM. This consideration also applies to Signature bytes
reading.
Note: The EEPROM memory is preserved during Chip Erase if the EESAVE Fuse is programmed.
180 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
While the lower bits in the address are mapped to words within the page, the higher bits address
the pages within the FLASH. This is illustrated in Figure 18-4. Note that if less than eight bits are
required to address words in the page (pagesize < 256), the most significant bit(s) in the address
low byte are used to address the page when performing a Page Write.
181
2588E–AVR–08/10
Figure 18-4. Addressing the Flash Which is Organized in Pages
PCMSB PAGEMSB
PROGRAM
PCPAGE PCWORD
COUNTER
01
02
PAGEEND
Note: PCPAGE and PCWORD are listed in Table 18-7 on page 173.
In the figure below, “XX” means don’t care. The numbers in the figure refer to the programming
description above.
WR
STEP
1 2 3 4 2 3 4 6 7 9
DATA 0x10 ADDR. LOW DATA LOW DATA HIGH ADDR. LOW DATA LOW DATA HIGH ADDR. HIGH XXX 0x00
XA1 / BS2
XA0
PAGEL / BS1
XTAL1
WR
RDY / BSY
RESET +12V
OE
182 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
programmed simultaneously. The programming algorithm for the EEPROM data memory is as
follows (refer to “Programming the Flash” on page 180 for details on Command, Address and
Data loading):
1. A: Load Command “0001 0001”.
2. G: Load Address High Byte (0x00 - 0xFF).
3. B: Load Address Low Byte (0x00 - 0xFF).
4. C: Load Data (0x00 - 0xFF).
5. E: Latch data (give PAGEL a positive pulse).
6. K: Repeat 3 through 5 until the entire buffer is filled.
7. L: Program EEPROM page
a. Set BS to “0”.
b. Give WR a negative pulse. This starts programming of the EEPROM page.
RDY/BSY goes low.
c. Wait until to RDY/BSY goes high before programming the next page (See Figure
18-6 for signal waveforms).
A G B C E B C E L
0x11 ADDR. HIGH ADDR. LOW DATA XX ADDR. LOW DATA XX
DATA
XA1/BS2
XA0
PAGEL/BS1
XTAL1
WR
RDY/BSY
RESET +12V
OE
183
2588E–AVR–08/10
18.7.8 Reading the EEPROM
The algorithm for reading the EEPROM memory is as follows (refer to “Programming the Flash”
on page 180 for details on Command and Address loading):
1. A: Load Command “0000 0011”.
2. G: Load Address High Byte (0x00 - 0xFF).
3. B: Load Address Low Byte (0x00 - 0xFF).
4. Set OE to “0”, and BS1 to “0”. The EEPROM Data byte can now be read at DATA.
5. Set OE to “1”.
184 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
A C A C A C
0x40 DATA XX 0x40 DATA XX 0x40 DATA XX
DATA
XA1/BS2
XA0
PAGEL/BS1
XTAL1
WR
RDY/BSY
RESET +12V
OE
185
2588E–AVR–08/10
Figure 18-8. Mapping Between BS1, BS2 and the Fuse and Lock Bits During Read
0
Extended Fuse Byte 1
DATA
BS2
Lock Bits 0
1
BS1
Fuse High Byte 1
BS2
186 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
19.2 DC Characteristics
Table 19-1. DC Characteristics. TA = -40°C to +85°C, VCC = 1.8V to 5.5V (unless otherwise noted).
Symbol Parameter Condition Min Typ (1) Max Units
Except XTAL1 and
-0.5 0.2VCC(3) V
RESET pins
XTAL1 pin,
VIL Input Low-voltage -0.5 0.1VCC(3) V
External Clock Selected
RESET pin -0.5 0.2VCC(3) V
RESET pin as I/O -0.5 0.2VCC(3) V
Except XTAL1 and
0.7VCC(2) VCC +0.5 V
RESET pins
XTAL1 pin,
VIH Input High-voltage 0.8VCC(2) VCC +0.5 V
External Clock Selected
RESET pin 0.9VCC(2) VCC +0.5 V
(2)
RESET pin as I/O 0.7VCC VCC +0.5 V
(4)
Output Low Voltage IOL = 10 mA, VCC = 5V 0.6 V
VOL
(Except Reset pin) (6) IOL = 5 mA, VCC = 3V 0.5 V
Output High-voltage (5) IOH = -10 mA, VCC = 5V 4.3 V
VOH
(Except Reset pin) (6) IOH = -5 mA, VCC = 3V 2.5 V
Input Leakage Vcc = 5.5V, pin low
IIL < 0.05 1 µA
Current I/O Pin (absolute value)
Input Leakage Vcc = 5.5V, pin high
IIH < 0.05 1 µA
Current I/O Pin (absolute value)
RRST Reset Pull-up Resistor 30 60 kΩ
RPU I/O Pin Pull-up Resistor 20 50 kΩ
187
2588E–AVR–08/10
Table 19-1. DC Characteristics. TA = -40°C to +85°C, VCC = 1.8V to 5.5V (unless otherwise noted).
Symbol Parameter Condition Min Typ (1) Max Units
Active 1MHz, VCC = 2V 0.4 0.6 mA
Active 4MHz, VCC = 3V 2 3 mA
Active 8MHz, VCC = 5V 6 9 mA
Power Supply Current (7)
Idle 1MHz, VCC = 2V 0.1 0.3 mA
ICC
Idle 4MHz, VCC = 3V 0.4 1 mA
Idle 8MHz, VCC = 5V 1.5 3 mA
WDT enabled, VCC = 3V 4 10 µA
Power-down mode (8)
WDT disabled, VCC = 3V 0.15 2 µA
Notes: 1. Typical values at +25°C.
2. “Min” means the lowest value where the pin is guaranteed to be read as high.
3. “Max” means the highest value where the pin is guaranteed to be read as low.
4. Although each I/O port can sink more than the test conditions (10 mA at VCC = 5V, 5 mA at VCC = 3V) under steady state
conditions (non-transient), the sum of all IOL (for all ports) should not exceed 60 mA. If IOL exceeds the test conditions, VOL
may exceed the related specification. Pins are not guaranteed to sink current greater than the listed test condition.
5. Although each I/O port can source more than the test conditions (10 mA at VCC = 5V, 5 mA at VCC = 3V) under steady state
conditions (non-transient), the sum of all IOH (for all ports) should not exceed 60 mA. If IOH exceeds the test condition, VOH
may exceed the related specification. Pins are not guaranteed to source current greater than the listed test condition.
6. The RESET pin must tolerate high voltages when entering and operating in programming modes and, as a consequence,
has a weak drive strength as compared to regular I/O pins. See Figure 20-23, Figure 20-24, Figure 20-25, and Figure 20-26
(starting on page 209).
7. Values are with external clock using methods described in “Minimizing Power Consumption” on page 37. Power Reduction
is enabled (PRR = 0xFF) and there is no I/O drive.
8. BOD Disabled.
19.3 Speed
The maximum operating frequency of the device depends on VCC. As shown in Figure 19-1 and
Figure 19-2, the maximum frequency vs. VCC relationship is linear between 1.8V < VCC < 2.7V
and between 2.7V < VCC < 4.5V.
10 MHz
188 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
20 MHz
10 MHz
Safe Operating Area
Notes: 1. Accuracy of oscillator frequency at calibration point (fixed temperature and fixed voltage).
2. Voltage range for ATtiny261V/461V/861V.
3. Voltage range for ATtiny261/461/861.
V IH1
V IL1
189
2588E–AVR–08/10
Table 19-3. External Clock Drive Characteristics
VCC = 1.8 - 5.5V VCC = 2.7 - 5.5V VCC = 4.5 - 5.5V
Symbol Parameter Min. Max. Min. Max. Min. Max. Units
1/tCLCL Clock Frequency 0 4 0 10 0 20 MHz
tCLCL Clock Period 250 100 50 ns
tCHCX High Time 100 40 20 ns
tCLCX Low Time 100 40 20 ns
tCLCH Rise Time 2.0 1.6 0.5 μs
tCHCL Fall Time 2.0 1.6 0.5 μs
ΔtCLCL Change in period from one clock cycle to the next 2 2 2 %
190 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Note: 1. VBOT may be below nominal minimum operating voltage for some devices. For devices where
this is the case, the device is tested down to VCC = VBOT during the production test. This guar-
antees that a Brown-out Reset will occur before VCC drops to a voltage where correct
operation of the microcontroller is no longer guaranteed.
191
2588E–AVR–08/10
19.6 ADC Characteristics
Table 19-7. ADC Characteristics, Single Ended Channels. T = -40°C to +85°C
Symbol Parameter Condition Min(1) Typ(1) Max(1) Units
Resolution 10 Bits
VREF = 4V, VCC = 4V,
2 LSB
ADC clock = 200 kHz
VREF = 4V, VCC = 4V,
3 LSB
Absolute accuracy ADC clock = 1 MHz
(Including INL, DNL, and VREF = 4V, VCC = 4V,
Quantization, Gain and Offset ADC clock = 200 kHz 1.5 LSB
Errors) Noise Reduction Mode
VREF = 4V, VCC = 4V,
ADC clock = 1 MHz 2.5 LSB
Noise Reduction Mode
Integral Non-Linearity (INL)
VREF = 4V, VCC = 4V,
(Accuracy after Offset and 1 LSB
ADC clock = 200 kHz
Gain Calibration)
VREF = 4V, VCC = 4V,
Differential Non-linearity (DNL) 0.5 LSB
ADC clock = 200 kHz
VREF = 4V, VCC = 4V,
Gain Error 2.5 LSB
ADC clock = 200 kHz
VREF = 4V, VCC = 4V,
Offset Error 1.5 LSB
ADC clock = 200 kHz
Conversion Time Free Running Conversion 13 260 µs
Clock Frequency 50 1000 kHz
AVCC Analog Supply Voltage VCC - 0.3 VCC + 0.3 V
Single Ended Conversions 2.0 AVCC V
AREF External Voltage Reference
Differential Conversions 2.0 AVCC - 1.0 V
Single Ended Conversions GND VREF
VIN Input Voltage
Differential Conversions 0 AVCC (2) V
Single Ended Conversions 38.5
Input Bandwidth kHz
Differential Conversions 4
Internal 1.1V Reference 1.0 1.1 1.2 V
VINT
(2)
Internal 2.56V Reference 2.3 2.56 2.8 V
RREF Reference Input Resistance 35 kΩ
RAIN Analog Input Resistance 100 MΩ
ADC Conversion Output 0 1023 LSB
Note: 1. Values are guidelines, only.
2. VDIFF must be below VREF.
192 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
SAMPLE
MOSI
tOVSH tSHOX tSLSH
SCK
tSHSL
MISO
tSLIV
Table 19-8. Serial Programming Characteristics, TA = -40°C to +85°C, VCC = 1.8 - 5.5V
(Unless Otherwise Noted)
Symbol Parameter Min Typ Max Units
1/tCLCL Oscillator Frequency (ATtiny261V/461V/861V) 0 4 MHz
tCLCL Oscillator Period (ATtiny261V/461V/861V) 250 ns
Oscillator Frequency
1/tCLCL 0 20 MHz
(ATtiny261/461/861, VCC = 4.5 - 5.5V)
Oscillator Period
tCLCL 50 ns
(ATtiny261/461/861, VCC = 4.5 - 5.5V)
tSHSL SCK Pulse Width High 2 tCLCL(1) ns
tSLSH SCK Pulse Width Low 2 tCLCL(1) ns
tOVSH MOSI Setup to SCK High tCLCL ns
tSHOX MOSI Hold after SCK High 2 tCLCL ns
tSLIV SCK Low to MISO Valid 100 ns
Note: 1. 2 tCLCL for fck < 12 MHz, 3 tCLCL for fck >= 12 MHz
193
2588E–AVR–08/10
19.8 Parallel Programming Characteristics
Figure 19-6. Parallel Programming Timing, Including some General Timing Requirements
tXLWL
tXHXL
XTAL1
tDVXH tXLDX
Data & Contol
(DATA, XA0, XA1/BS2, PAGEL/BS1)
tBVPH tPLBX t BVWL
tWLBX
tWLWH
WR tPLWL
WLRL
RDY/BSY
tWLRH
Figure 19-7. Parallel Programming Timing, Loading Sequence with Timing Requirements
LOAD ADDRESS LOAD DATA LOAD DATA LOAD ADDRESS
(LOW BYTE) (LOW BYTE) (HIGH BYTE) (LOW BYTE)
t XLXH
XTAL1
PAGEL/BS1
DATA ADDR0 (Low Byte) DATA (Low Byte) DATA (High Byte) ADDR1 (Low Byte)
XA0
XA1/BS2
Note: The timing requirements shown in Figure 19-6 (i.e., tDVXH, tXHXL, and tXLDX) also apply to loading operation.
194 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Figure 19-8. Parallel Programming Timing, Reading Sequence (within the Same Page) with Timing Requirements
LOAD ADDRESS READ DATA READ DATA LOAD ADDRESS
(LOW BYTE) (LOW BYTE) (HIGH BYTE) (LOW BYTE)
tXLOL
XTAL1
tBVDV
PAGEL/BS1
tOLDV
OE
tOHDZ
DATA ADDR0 (Low Byte) DATA (Low Byte) DATA (High Byte) ADDR1 (Low Byte)
XA0
XA1/BS2
Note: The timing requirements shown in Figure 19-6 (i.e., tDVXH, tXHXL, and tXLDX) also apply to reading operation.
195
2588E–AVR–08/10
Table 19-9. Parallel Programming Characteristics, VCC = 5V ± 10% (Continued)
Symbol Parameter Min Typ Max Units
tBVDV BS1 Valid to DATA valid 0 250 ns
tOLDV OE Low to DATA Valid 250 ns
tOHDZ OE High to DATA Tri-stated 250 ns
Notes: 1. tWLRH is valid for the Write Flash, Write EEPROM, Write Fuse bits and Write Lock bits
commands.
2. tWLRH_CE is valid for the Chip Erase command.
196 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
where VCC = operating voltage, CL = load capacitance and fSW = average switching frequency of
I/O pin.
Table 20-1. Additional Current Consumption for the different I/O modules (absolute values).
Typical numbers
PRR bit VCC = 2V, f = 1MHz VCC = 3V, f = 4MHz VCC = 5V, f = 8MHz
PRTIM1 65 µA 423 µA 1787 µA
PRTIM0 7 µA 39 µA 165 µA
PRUSI 5 µA 25 µA 457 µA
PRADC 18 µA 111 µA 102 µA
Table 20-2 below can be used for calculating typical current consumption for other supply volt-
ages and frequencies than those mentioned in the Table 20-1 above.
197
2588E–AVR–08/10
Table 20-2. Additional Current Consumption (percentage) in Active and Idle mode.
Additional Current consumption Additional Current consumption
compared to Active with external compared to Idle with external
clock (see Figure 20-1 on page clock (see Figure 20-6 on page
PRR bit 198 and Figure 20-2 on page 199) 201 and Figure 20-7 on page 201)
PRTIM1 26.9 % 103.7 %
PRTIM0 2.6 % 10.0 %
PRUSI 1.7 % 6.5 %
PRADC 7.1 % 27.3 %
It is possible to calculate the typical current consumption based on the numbers from Table 20-1
for other VCC and frequency settings than listed in Table 20-2.
20.1.0.1 Example
Calculate the expected current consumption in idle mode with TIMER0, ADC, and USI enabled
at VCC = 2.0V and F = 1MHz. From Table 20-2, third column, we see that we need to add 10%
for the TIMER0, 27.3 % for the ADC, and 6.5 % for the USI module. Reading from Figure 20-6
on page 201, we find that the idle current consumption is ~0,085 mA at VCC = 2.0V and F=1MHz.
The total current consumption in idle mode with TIMER0, ADC, and USI enabled, gives:
I CC total ≈ 0,085mA • ( 1 + 0,10 + 0,273 + 0,065 ) ≈ 0,122mA
Figure 20-1. Active Supply Current vs. Low Frequency (0.1 - 1.0 MHz)
ACTIVE SUPPLY CURRENT vs. LOW FREQUENCY
0.1 - 1.0 MHZ
1,2
5.5 V
1
5.0 V
0,8
4.5 V
4.0 V
ICC (mA)
0,6
3.3 V
0,4
2.7 V
1.8 V
0,2
0
0 0,1 0,2 0,3 0,4 0,5 0,6 0,7 0,8 0,9 1
Frequency (MHz)
198 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
14
5.5 V
12
5.0 V
10 4.5 V
ICC (mA)
6
4.0 V
3.3 V
4
2.7 V
2
1.8 V
0
0 2 4 6 8 10 12 14 16 18 20
Frequency (MHz)
Figure 20-3. Active Supply Current vs. VCC (Internal RC Oscillator, 8 MHz)
ACTIVE SUPPLY CURRENT vs. VCC
INTERNAL RC OSCILLATOR, 8 MHz
7
85 ˚C
6 25 ˚C
-40 ˚C
5
I CC (mA)
0
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
199
2588E–AVR–08/10
Figure 20-4. Active Supply Current vs. VCC (Internal RC Oscillator, 1 MHz)
ACTIVE SUPPLY CURRENT vs. VCC
INTERNAL RC OSCILLATOR, 1 MHz
1,6
85 ˚C
1,4
25 ˚C
1,2
1 -40 ˚C
I CC (mA)
0,8
0,6
0,4
0,2
0
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
Figure 20-5. Active Supply Current vs. VCC (Internal RC Oscillator, 128 kHz)
ACTIVE SUPPLY CURRENT vs. VCC
INTERNAL RC OSCILLATOR, 128 kHz
0,3
0,25 85 ˚C
0,2
-40 ˚C
ICC (mA)
25 ˚C
0,15
0,1
0,05
0
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
200 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Figure 20-6. Idle Supply Current vs. Low Frequency (0.1 - 1.0 MHz)
IDLE SUPPLY CURRENT vs. LOW FREQUENCY
0.1 - 1.0 MHz
0,3
5.5 V
0,25
5.0 V
0,2 4.5 V
4.0 V
I CC (mA)
0,15 3.3 V
2.7 V
0,1
1.8 V
0,05
0
0 0,1 0,2 0,3 0,4 0,5 0,6 0,7 0,8 0,9 1
Frequency (MHz)
4 5.5 V
3,5 5.0 V
3 4.5 V
ICC (mA)
2,5
4.0 V
2
1,5
3.3 V
1
2.7 V
0,5
1.8 V
0
0 2 4 6 8 10 12 14 16 18 20
Frequency (MHz)
201
2588E–AVR–08/10
Figure 20-8. Idle Supply Current vs. VCC (Internal RC Oscillator, 8 MHz)
IDLE SUPPLY CURRENT vs. VCC
INTERNAL RC OSCILLATOR, 8 MHz
2,5
2 85 ˚C
25 ˚C
-40 ˚C
1,5
ICC (mA)
0,5
0
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
Figure 20-9. Idle Supply Current vs. VCC (Internal RC Oscillator, 1 MHz)
IDLE SUPPLY CURRENT vs. VCC
INTERNAL RC OSCILLATOR, 1 MHz
0,7
0,6
85 ˚C
0,5 25 ˚C
-40 ˚C
I CC (mA)
0,4
0,3
0,2
0,1
0
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
202 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Figure 20-10. Idle Supply Current vs. VCC (Internal RC Oscillator, 128 kHz)
IDLE SUPPLY CURRENT vs. VCC
INTERNAL RC OSCILLATOR, 128 kHz
0,2
0,18 85 ˚C
0,16
0,14
0,12
I CC (mA)
0,1 25 ˚C
0,08 -40 ˚C
0,06
0,04
0,02
0
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
Figure 20-11. Power-down Supply Current vs. VCC (Watchdog Timer Disabled)
POWER-DOWN SUPPLY CURRENT vs. VCC
WATCHDOG TIMER DISABLED
1,6
1,4
85 ˚C
1,2
1
ICC (uA)
0,8
-40 ˚C
0,6
25 ˚C
0,4
0,2
0
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
203
2588E–AVR–08/10
Figure 20-12. Power-down Supply Current vs. VCC (Watchdog Timer Enabled)
POWER-DOWN SUPPLY CURRENT vs. VCC
WATCHDOG TIMER ENABLED
10
-40 ˚C
9
85 ˚C
8
25 ˚C
7
6
I CC (uA)
0
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
Figure 20-13. I/O Pin pull-up Resistor Current vs. Input Voltage (VCC = 1.8V)
I/O PIN PULL-UP RESISTOR CURRENT vs. INPUT VOLTAGE
VCC = 1.8V
60
50
40
IOP (uA)
30
20
25 ˚C
10
85 ˚C
-40 ˚C
0
0 0,2 0,4 0,6 0,8 1 1,2 1,4 1,6 1,8 2
VOP (V)
204 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Figure 20-14. I/O Pin pull-up Resistor Current vs. Input Voltage (VCC = 2.7V)
I/O PIN PULL-UP RESISTOR CURRENT vs. INPUT VOLTAGE
VCC = 2.7V
90
80
70
60
IOP (uA)
50
40
30
25 ˚C
20
85 ˚C
10
-40 ˚C
0
0 0,5 1 1,5 2 2,5 3
VOP (V)
Figure 20-15. I/O Pin pull-up Resistor Current vs. Input Voltage (VCC = 5V)
I/O PIN PULL-UP RESISTOR CURRENT vs. INPUT VOLTAGE
VCC = 5V
160
140
120
100
IOP (uA)
80
60
40
25 ˚C
20 85 ˚C
-40 ˚C
0
0 1 2 3 4 5 6
VOP (V)
205
2588E–AVR–08/10
Figure 20-16. Reset Pull-up Resistor Current vs. Reset Pin Voltage (VCC = 1.8V)
35
30
25
IRESET(uA)
20
15
10
25 ˚C
5 -40 ˚C
0
85 ˚C
0 0,2 0,4 0,6 0,8 1 1,2 1,4 1,6 1,8 2
VRESET(V)
Figure 20-17. Reset Pull-up Resistor Current vs. Reset Pin Voltage (VCC = 2.7V)
RESET PULL-UP RESISTOR CURRENT vs. RESET PIN VOLTAGE
VCC = 2.7V
70
60
50
IRESET(uA)
40
30
20
25 ˚C
10
-40 ˚C
85 ˚C
0
0 0,5 1 1,5 2 2,5 3
VRESET(V)
206 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Figure 20-18. Reset Pull-up Resistor Current vs. Reset Pin Voltage (VCC = 5V)
RESET PULL-UP RESISTOR CURRENT vs. RESET PIN VOLTAGE
VCC = 5V
120
100
80
IRESET(uA)
60
40
25 ˚C
20
-40 ˚C
85 ˚C
0
0 1 2 3 4 5 6
VRESET(V)
Figure 20-19. I/O Pin Output Voltage vs. Sink Current (VCC = 3V)
I/O PIN OUTPUT VOLTAGE vs. SINK CURRENT
VCC = 3V
0,9
85 ˚C
0,8
0,7
25 ˚C
0,6
-40 ˚C
VOL (V)
0,5
0,4
0,3
0,2
0,1
0
0 5 10 15 20 25
IOL (mA)
207
2588E–AVR–08/10
Figure 20-20. I/O Pin Output Voltage vs. Sink Current (VCC = 5V)
I/O PIN OUTPUT VOLTAGE vs. SINK CURRENT
VCC = 5V
0,6
85 ˚C
0,5
25 ˚C
0,4
-40 ˚C
VOL (V)
0,3
0,2
0,1
0
0 5 10 15 20 25
IOL (mA)
Figure 20-21. I/O Pin Output Voltage vs. Source Current (VCC = 3V)
I/O PIN OUTPUT VOLTAGE vs. SOURCE CURRENT
VCC = 3V
3,1
2,9
2,7
2,5
VOH (V)
2,3 -40 ˚C
25 ˚C
2,1
85 ˚C
1,9
1,7
1,5
0 5 10 15 20 25
IOH (mA)
208 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Figure 20-22. I/O Pin Output Voltage vs. Source Current (VCC = 5V)
4,8
4,6
VOH (V)
-40 ˚C
25 ˚C
4,4
85 ˚C
4,2
4
0 5 10 15 20 25
IOH (mA)
Figure 20-23. Reset Pin Output Voltage vs. Sink Current (VCC = 3V)
RESET AS I/O PIN OUTPUT VOLTAGE vs. SINK CURRENT
VCC = 3V
1.5
85 °C
1
VOL (V)
0 °C
-45 °C
0.5
0
0 0.5 1 1.5 2 2.5 3
IOL (mA)
209
2588E–AVR–08/10
Figure 20-24. Reset Pin Output Voltage vs. Sink Current (VCC = 5V)
0.8
0.4 0 °C
-45 °C
0.2
0
0 0.5 1 1.5 2 2.5 3
IOL (mA)
Figure 20-25. Reset Pin Output Voltage vs. Source Current (VCC = 3V)
RESET AS I/O PIN OUTPUT VOLTAGE vs. SOURCE CURRENT
VCC = 3V
3.5
2.5
2
VOH (V)
1.5
-45 °C
1 25 °C
85 °C
0.5
0
0 0.5 1 1.5 2
IOH (mA)
210 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Figure 20-26. Reset Pin Output Voltage vs. Source Current (VCC = 5V)
RESET AS I/O PIN OUTPUT VOLTAGE vs. SOURCE CURRENT
VCC = 5V
4.5
4
VOH (V)
3.5
3
-45 °C
25 °C
2.5 85 °C
0 0.5 1 1.5 2
IOH (mA)
Figure 20-27. I/O Pin Input Threshold Voltage vs. VCC (VIH, I/O Pin Read as ‘1’)
I/O PIN INPUT THRESHOLD VOLTAGE vs. VCC
VIH, IO PIN READ AS '1'
3,5
-40 ˚C
3
25 ˚C
85 ˚C
2,5
Threshold (V)
1,5
0,5
0
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
211
2588E–AVR–08/10
Figure 20-28. I/O Pin Input Threshold Voltage vs. VCC (VIL, I/O Pin Read as ‘0’)
I/O PIN INPUT THRESHOLD VOLTAGE vs. VCC
VIL, IO PIN READ AS '0'
3
85 ˚C
2,5 25 ˚C
Threshold (V)
-40 ˚C
2
1,5
0,5
0
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
0,7
0,6
0,5
-40 °C
Input Hysteresis (V)
25 °C
0,4 85 °C
0,3
0,2
0,1
0
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
212 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Figure 20-30. Reset Input Threshold Voltage vs. VCC (VIH, Reset Read as ‘1’)
1,5
0,5
0
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
Figure 20-31. Reset Input Threshold Voltage vs. VCC (VIL, Reset Read as ‘0’)
RESET PIN AS I/O THRESHOLD VOLTAGE vs. VCC
VIL, RESET READ AS '0'
2,5
85 ˚C
25 ˚C
2
-40 ˚C
Threshold (V)
1,5
0,5
0
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
213
2588E–AVR–08/10
Figure 20-32. Reset Pin input Hysteresis vs. VCC
RESET PIN INPUT HYSTERESIS vs. VCC
0,9
0,8
0,4
0,3
0,2
0,1
0
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
4,45
4,4
Threshold (V)
4,35
Rising VCC
4,3
4,25
Falling VCC
4,2
4,15
4,1
-60 -40 -20 0 20 40 60 80 100
Temperature (C)
214 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
2,85
Rising VCC
2,75
2,7
2,65
Falling VCC
2,6
2,55
2,5
-60 -40 -20 0 20 40 60 80 100
Temperature (C)
1,95
1,9
Threshold (V)
1,85
Rising VCC
1,8
Falling VCC
1,75
1,7
1,65
1,6
-60 -40 -20 0 20 40 60 80 100
Temperature (C)
215
2588E–AVR–08/10
Figure 20-36. Bandgap Voltage vs. Supply Voltage (VCC).
1.08
85 °C
1.07
Bandgap Voltage ( V ) 25 °C
1.06
-40 °C
1.05
1.04
1.5 2 2.5 3 3.5 4 4.5 5 5.5
VCC ( V )
0,138
0,136
0,134
-40 ˚C
0,132
FRC (MHz)
0,13
0,128 25 ˚C
0,126
0,124
0,122
85 ˚C
0,12
0,118
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
216 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
8,8
8,6
85 ˚C
FRC (MHz) 8,4
8,2
25 ˚C
8
7,8
7,6
-40 ˚C
7,4
7,2
7
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
8,8
8,6
5.0 V
8,4
FRC (MHz)
8,2
3.0 V
8
7,8
7,6
7,4
7,2
7
-60 -40 -20 0 20 40 60 80 100
Temperature
217
2588E–AVR–08/10
Figure 20-40. Calibrated 8.0 MHz RC Oscillator Frequency vs. OSCCAL Value
18
85 ˚C
16
25 ˚C
14
-40 ˚C
12
FRC (MHz)
10
0
0 16 32 48 64 80 96 112 128 144 160 176 192 208 224 240 256
OSCCAL (X1)
900
25 ˚C
800
700
600
ICC (uA)
500
400
300
200
100
0
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
218 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
180
25 ˚C
150
120
ICC (uA)
90
60
30
0
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
160
140
120
100
ICC (uA)
80 25 ˚C
60
40
20
0
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
219
2588E–AVR–08/10
Figure 20-44. Brownout Detector Current vs. VCC
BROWNOUT DETECTOR CURRENT vs. VCC
30
85 ˚C
25
25 ˚C
-40 ˚C
20
I CC (uA)
15
10
0
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
16000
14000 25 ˚C
12000
10000
I CC (uA)
8000
6000
4000
2000
0
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
220 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
10
9 -40 ˚C
85 ˚C
8
25 ˚C
7
6
ICC (uA)
0
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
Figure 20-47. Reset Supply Current vs. Low Frequency (0.1 - 1.0 MHz, Excluding Current
Through the Reset Pull-up)
RESET SUPPLY CURRENT vs. Low Frequency
0.1 - 1.0 MHz, EXCLUDING CURRENT THROUGH THE RESET PULL-UP
0,14
5.5 V
0,12
5.0 V
0,1
4.5 V
4.0 V
ICC (mA)
0,08
0,06 3.3 V
2.7 V
0,04
1.8 V
0,02
0
0 0,1 0,2 0,3 0,4 0,5 0,6 0,7 0,8 0,9 1
Frequency (MHz)
221
2588E–AVR–08/10
Figure 20-48. Reset Supply Current vs. Frequency (1 - 20 MHz, Excluding Current Through the
Reset Pull-up)
RESET SUPPLY CURRENT vs. VCC
1 - 20 MHz, EXCLUDING CURRENT THROUGH THE RESET PULLUP
2,5
5.5 V
5.0 V
2
4.5 V
1,5
ICC (mA)
4.0 V
1
3.3 V
0,5
2.7 V
1.8 V
0
0 2 4 6 8 10 12 14 16 18 20
Frequency (MHz)
2500
2000
Pulsewidth (ns)
1500
1000
500 85 ˚C
25 ˚C
-40 ˚C
0
1,5 2 2,5 3 3,5 4 4,5 5 5,5
VCC (V)
222 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
223
2588E–AVR–08/10
Note: 1. For compatibility with future devices, reserved bits should be written to zero if accessed. Reserved I/O memory addresses
should never be written.
2. I/O Registers within the address range 0x00 - 0x1F are directly bit-accessible using the SBI and CBI instructions. In these
registers, the value of single bits can be checked by using the SBIS and SBIC instructions.
3. Some of the Status Flags are cleared by writing a logical one to them. Note that, unlike most other AVRs, the CBI and SBI
instructions will only operation the specified bit, and can therefore be used on registers containing such Status Flags. The
CBI and SBI instructions work with registers 0x00 to 0x1F only.
224 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
225
2588E–AVR–08/10
Mnemonics Operands Description Operation Flags #Clocks
ASR Rd Arithmetic Shift Right Rd(n) ← Rd(n+1), n=0..6 Z,C,N,V 1
SWAP Rd Swap Nibbles Rd(3..0)←Rd(7..4),Rd(7..4)←Rd(3..0) None 1
BSET s Flag Set SREG(s) ← 1 SREG(s) 1
BCLR s Flag Clear SREG(s) ← 0 SREG(s) 1
BST Rr, b Bit Store from Register to T T ← Rr(b) T 1
BLD Rd, b Bit load from T to Register Rd(b) ← T None 1
SEC Set Carry C←1 C 1
CLC Clear Carry C←0 C 1
SEN Set Negative Flag N←1 N 1
CLN Clear Negative Flag N←0 N 1
SEZ Set Zero Flag Z←1 Z 1
CLZ Clear Zero Flag Z←0 Z 1
SEI Global Interrupt Enable I←1 I 1
CLI Global Interrupt Disable I←0 I 1
SES Set Signed Test Flag S←1 S 1
CLS Clear Signed Test Flag S←0 S 1
SEV Set Twos Complement Overflow. V←1 V 1
CLV Clear Twos Complement Overflow V←0 V 1
SET Set T in SREG T←1 T 1
CLT Clear T in SREG T←0 T 1
SEH Set Half Carry Flag in SREG H←1 H 1
CLH Clear Half Carry Flag in SREG H←0 H 1
DATA TRANSFER INSTRUCTIONS
MOV Rd, Rr Move Between Registers Rd ← Rr None 1
MOVW Rd, Rr Copy Register Word Rd+1:Rd ← Rr+1:Rr None 1
LDI Rd, K Load Immediate Rd ← K None 1
LD Rd, X Load Indirect Rd ← (X) None 2
LD Rd, X+ Load Indirect and Post-Inc. Rd ← (X), X ← X + 1 None 2
LD Rd, - X Load Indirect and Pre-Dec. X ← X - 1, Rd ← (X) None 2
LD Rd, Y Load Indirect Rd ← (Y) None 2
LD Rd, Y+ Load Indirect and Post-Inc. Rd ← (Y), Y ← Y + 1 None 2
LD Rd, - Y Load Indirect and Pre-Dec. Y ← Y - 1, Rd ← (Y) None 2
LDD Rd,Y+q Load Indirect with Displacement Rd ← (Y + q) None 2
LD Rd, Z Load Indirect Rd ← (Z) None 2
LD Rd, Z+ Load Indirect and Post-Inc. Rd ← (Z), Z ← Z+1 None 2
LD Rd, -Z Load Indirect and Pre-Dec. Z ← Z - 1, Rd ← (Z) None 2
LDD Rd, Z+q Load Indirect with Displacement Rd ← (Z + q) None 2
LDS Rd, k Load Direct from SRAM Rd ← (k) None 2
ST X, Rr Store Indirect (X) ← Rr None 2
ST X+, Rr Store Indirect and Post-Inc. (X) ← Rr, X ← X + 1 None 2
ST - X, Rr Store Indirect and Pre-Dec. X ← X - 1, (X) ← Rr None 2
ST Y, Rr Store Indirect (Y) ← Rr None 2
ST Y+, Rr Store Indirect and Post-Inc. (Y) ← Rr, Y ← Y + 1 None 2
ST - Y, Rr Store Indirect and Pre-Dec. Y ← Y - 1, (Y) ← Rr None 2
STD Y+q,Rr Store Indirect with Displacement (Y + q) ← Rr None 2
ST Z, Rr Store Indirect (Z) ← Rr None 2
ST Z+, Rr Store Indirect and Post-Inc. (Z) ← Rr, Z ← Z + 1 None 2
ST -Z, Rr Store Indirect and Pre-Dec. Z ← Z - 1, (Z) ← Rr None 2
STD Z+q,Rr Store Indirect with Displacement (Z + q) ← Rr None 2
STS k, Rr Store Direct to SRAM (k) ← Rr None 2
LPM Load Program Memory R0 ← (Z) None 3
LPM Rd, Z Load Program Memory Rd ← (Z) None 3
LPM Rd, Z+ Load Program Memory and Post-Inc Rd ← (Z), Z ← Z+1 None 3
SPM Store Program Memory (z) ← R1:R0 None
IN Rd, P In Port Rd ← P None 1
OUT P, Rr Out Port P ← Rr None 1
PUSH Rr Push Register on Stack STACK ← Rr None 2
POP Rd Pop Register from Stack Rd ← STACK None 2
MCU CONTROL INSTRUCTIONS
NOP No Operation None 1
SLEEP Sleep (see specific descr. for Sleep function) None 1
WDR Watchdog Reset (see specific descr. for WDR/Timer) None 1
BREAK Break For On-chip Debug Only None N/A
226 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Package Type
32M1-A 32-pad, 5 x 5 x 1.0 mm Body, Lead Pitch 0.50 mm, Micro Lead Frame Package (MLF)
20P3 20-lead, 0.300" Wide, Plastic Dual Inline Package (PDIP)
20S2 20-lead, 0.300" Wide, Plastic Gull Wing Smal Outline Package (SOIC)
227
2588E–AVR–08/10
23.2 ATtiny461
Speed (MHz)(3) Power Supply (V) Ordering Code(4) Package(2) Operational Range
ATtiny461V-10MU 32M1-A
ATtiny461V-10MUR 32M1-A
Industrial
10 1.8 - 5.5 ATtiny461V-10PU 20P3
(-40°C to +85°C)(1)
ATtiny461V-10SU 20S2
ATtiny461V-10SUR 20S2
ATtiny461-20MU 32M1-A
ATtiny461-20MUR 32M1-A
Industrial
20 2.7 - 5.5 ATtiny461-20PU 20P3
(-40°C to +85°C)(1)
ATtiny461-20SU 20S2
ATtiny461-20SUR 20S2
Notes: 1. These devices can also be supplied in wafer form. Please contact your local Atmel sales office for detailed ordering informa-
tion and minimum quantities.
2. All packages are Pb-free, halide-free and fully green and they comply with the European directive for Restriction of Hazard-
ous Substances (RoHS).
3. For Speed vs. VCC, see Figure 19.3 on page 188.
4. Code indicators:
– U: matte tin
– R: tape & reel
Package Type
32M1-A 32-pad, 5 x 5 x 1.0 mm Body, Lead Pitch 0.50 mm, Micro Lead Frame Package (MLF)
20P3 20-lead, 0.300" Wide, Plastic Dual Inline Package (PDIP)
20S2 20-lead, 0.300" Wide, Plastic Gull Wing Smal Outline Package (SOIC)
228 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
23.3 ATtiny861
Speed (MHz)(3) Power Supply (V) Ordering Code(4) Package(2) Operational Range
ATtiny861V-10MU 32M1-A
ATtiny861V-10MUR 32M1-A
Industrial
10 1.8 - 5.5 ATtiny861V-10PU 20P3
(-40°C to +85°C)(1)
ATtiny861V-10SU 20S2
ATtiny861V-10SUR 20S2
ATtiny861-20MU 32M1-A
ATtiny861-20MUR 32M1-A
Industrial
20 2.7 - 5.5 ATtiny861-20PU 20P3
(-40°C to +85°C)(1)
ATtiny861-20SU 20S2
ATtiny861-20SUR 20S2
Notes: 1. These devices can also be supplied in wafer form. Please contact your local Atmel sales office for detailed ordering informa-
tion and minimum quantities.
2. All packages are Pb-free, halide-free and fully green and they comply with the European directive for Restriction of Hazard-
ous Substances (RoHS).
3. For Speed vs. VCC, see Figure 19.3 on page 188.
4. Code indicators:
– U: matte tin
– R: tape & reel
Package Type
32M1-A 32-pad, 5 x 5 x 1.0 mm Body, Lead Pitch 0.50 mm, Micro Lead Frame Package (MLF)
20P3 20-lead, 0.300" Wide, Plastic Dual Inline Package (PDIP)
20S2 20-lead, 0.300" Wide, Plastic Gull Wing Smal Outline Package (SOIC)
229
2588E–AVR–08/10
24. Packaging Information
24.1 32M1-A
D1
1
0
2
3 Pin 1 ID
E1 E SIDE VIEW
TOP VIEW A3
A2
A1
A
K
0.08 C COMMON DIMENSIONS
P (Unit of Measure = mm)
D2
SYMBOL MIN NOM MAX NOTE
A 0.80 0.90 1.00
1 A1 – 0.02 0.05
P
2 A2 – 0.65 1.00
Pin #1 Notch
(0.20 R) 3
A3 0.20 REF
E2
b 0.18 0.23 0.30
K D 5.00 BSC
D1 4.75 BSC
D2 2.95 3.10 3.25
E 5.00 BSC
b e L
E1 4.75BSC
8/19/04
TITLE DRAWING NO. REV.
2325 Orchard Parkway
32M1-A, 32-pad, 5 x 5 x 1.0 mm Body, Lead Pitch 0.50 mm, 32M1-A D
R San Jose, CA 95131 3.10 mm Exposed Pad, Micro Lead Frame Package (MLF)
230 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
24.2 20P3
D
PIN
1
E1
SEATING PLANE
A1
L
B
B1
e
COMMON DIMENSIONS
(Unit of Measure = mm)
C
SYMBOL MIN NOM MAX NOTE
eC
eB A – – 5.334
A1 0.381 – –
D 25.493 – 25.984 Note 2
E 7.620 – 8.255
E1 6.096 – 7.112 Note 2
B 0.356 – 0.559
Notes: 1. This package conforms to JEDEC reference MS-001, Variation AD. B1 1.270 – 1.551
2. Dimensions D and E1 do not include mold Flash or Protrusion. L 2.921 – 3.810
Mold Flash or Protrusion shall not exceed 0.25 mm (0.010").
C 0.203 – 0.356
eB – – 10.922
eC 0.000 – 1.524
e 2.540 TYP
1/12/04
TITLE DRAWING NO. REV.
2325 Orchard Parkway
20P3, 20-lead (0.300"/7.62 mm Wide) Plastic Dual 20P3 C
R San Jose, CA 95131 Inline Package (PDIP)
231
2588E–AVR–08/10
24.3 20S2
232 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
25. Errata
25.1.1 Rev A
No known errata.
25.2.1 Rev B
Yield improvement. No known errata.
25.2.2 Rev A
No known errata.
25.3.1 Rev B
No known errata.
25.3.2 Rev A
Not sampled.
233
2588E–AVR–08/10
26. Datasheet Revision History
Please note that the referring page numbers in this section refer to the complete document.
234 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
235
2588E–AVR–08/10
236 ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Table of Contents
Features ..................................................................................................... 1
2 Overview ................................................................................................... 4
2.1 Block Diagram ...................................................................................................4
3 About ......................................................................................................... 6
3.1 Resources .........................................................................................................6
3.2 Code Examples .................................................................................................6
3.3 Data Retention ...................................................................................................6
3.4 Disclaimer ..........................................................................................................6
5 Memories ................................................................................................ 15
5.1 In-System Re-programmable Flash Program Memory ....................................15
5.2 SRAM Data Memory ........................................................................................15
5.3 EEPROM Data Memory ..................................................................................16
5.4 I/O Memory ......................................................................................................20
5.5 Register Description ........................................................................................20
i
2588E–AVR–08/10
7.2 Power Reduction Register ...............................................................................37
7.3 Minimizing Power Consumption ......................................................................37
7.4 Register Description ........................................................................................39
9 Interrupts ................................................................................................ 50
9.1 Interrupt Vectors ..............................................................................................50
9.2 External Interrupts ...........................................................................................51
9.3 Register Description ........................................................................................52
11 Timer/Counter0 ...................................................................................... 71
11.1 Features ..........................................................................................................71
11.2 Overview ..........................................................................................................71
11.3 Clock Sources .................................................................................................72
11.4 Counter Unit ....................................................................................................74
11.5 Input Capture Unit ...........................................................................................75
11.6 Output Compare Unit .......................................................................................76
11.7 Modes of Operation .........................................................................................77
11.8 Timer/Counter Timing Diagrams .....................................................................79
11.9 Accessing Registers in 16-bit Mode ................................................................80
11.10 Register Description ........................................................................................84
12 Timer/Counter1 ...................................................................................... 89
12.1 Features ..........................................................................................................89
12.2 Overview ..........................................................................................................89
12.3 Clock Sources .................................................................................................92
12.4 Counter Unit ....................................................................................................93
12.5 Output Compare Unit .......................................................................................94
12.6 Dead Time Generator ......................................................................................96
ii ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
iii
2588E–AVR–08/10
16.6 Register Description ......................................................................................164
iv ATtiny261/461/861
2588E–AVR–08/10
ATtiny261/461/861
Table of Contents....................................................................................... i
v
2588E–AVR–08/10
Headquarters International
Product Contact
Literature Requests
www.atmel.com/literature
Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any
intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN ATMEL’S TERMS AND CONDI-
TIONS OF SALE LOCATED ON ATMEL’S WEB SITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY
WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDEN-
TAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT
OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no
representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications
and product descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided
otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel’s products are not intended, authorized, or warranted for use
as components in applications intended to support or sustain life.
© 2010 Atmel Corporation. All rights reserved. Atmel ®, Atmel logo and combinations thereof, AVR ® and others are registered trademarks, or
trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others.
2588E–AVR–08/10