8-bit Atmel tinyAVR Microcontroller with 16K Bytes In-System Programmable Flash ATtiny1634 Features * High Performance, Low Power AVR(R) 8-bit Microcontroller * Advanced RISC Architecture * * * * * * * * - 125 Powerful Instructions - Most Single Clock Cycle Execution - 32 x 8 General Purpose Working Registers - Fully Static Operation High Endurance, Non-volatile Memory Segments - 16K Bytes of In-System, Self-Programmable Flash Program Memory * Endurance: 10,000 Write/Erase Cycles - 256 Bytes of In-System Programmable EEPROM * Endurance: 100,000 Write/Erase Cycles - 1K Byte of Internal SRAM - Data retention: 20 years at 85C / 100 years at 25C - Programming Lock for Self-Programming Flash & EEPROM Data Security Peripheral Features - Dedicated Hardware and QTouch(R) Library Support for Capacitive Touch Sensing - One 8-bit and One 16-bit Timer/Counter with Two PWM Channels, Each - 12-channel, 10-bit ADC - Programmable Ultra Low Power Watchdog Timer - On-chip Analog Comparator - Two Full Duplex USARTs with Start Frame Detection - Universal Serial Interface - Slave I2C Serial Interface Special Microcontroller Features - debugWIRE On-chip Debug System - In-System Programmable via SPI Port - Internal and External Interrupt Sources * Pin Change Interrupt on 18 Pins - Low Power Idle, ADC Noise Reduction, Standby and Power-down Modes - Enhanced Power-on Reset Circuit - Programmable Brown-out Detection Circuit with Supply Voltage Sampling - Calibrated 8MHz Oscillator with Temperature Calibration Option - Calibrated 32kHz Ultra Low Power Oscillator - On-chip Temperature Sensor I/O and Packages - 18 Programmable I/O Lines - 20-pad QFN/MLF, and 20-pin SOIC Operating Voltage: - 1.8 - 5.5V Speed Grade: - 0 - 2MHz @ 1.8 - 5.5V - 0 - 8MHz @ 2.7 - 5.5V - 0 - 12MHz @ 4.5 - 5.5V Temperature Range: -40C to +85C Low Power Consumption - Active Mode: 0.2mA at 1.8V and 1MHz - Idle Mode: 30A at 1.8V and 1MHz - Power-Down Mode (WDT Enabled): 1A at 1.8V - Power-Down Mode (WDT Disabled): 100nA at 1.8V 8303G-AVR-11/2013 1. Pin Configurations Figure 1-1. Pinout of ATtiny1634 SOIC (PCINT8/TXD0/ADC5) PB0 (PCINT7/RXD0/ADC4) PA7 (PCINT6/OC1B/ADC3) PA6 (PCINT5/OC0B/ADC2) PA5 (PCINT4/T0/ADC1) PA4 (PCINT3/T1/SNS/ADC0) PA3 (PCINT2/AIN1) PA2 (PCINT1/AIN0) PA1 (PCINT0/AREF) PA0 GND 1 2 3 4 5 6 7 8 9 10 20 19 18 17 16 15 14 13 12 11 PB1 (ADC6/DI/SDA/RXD1/PCINT9) PB2 (ADC7/DO/TXD1/PCINT10) PB3 (ADC8/OC1A/PCINT11) PC0 (ADC9/OC0A/XCK0/PCINT12) PC1 (ADC10/ICP1/SCL/USCK/XCK1/PCINT13) PC2 (ADC11/CLKO/INT0/PCINT14) PC3 (RESET/dW/PCINT15) PC4 (XTAL2/PCINT16) PC5 (XTAL1/CLKI/PCINT17) VCC NOTE Bottom pad should be soldered to ground. 15 14 13 12 11 6 7 8 9 10 1 2 3 4 5 PC0 (ADC9/OC0A/XCK0/PCINT12) PC1 (ADC10/ICP1/SCL/USCK/XCK1/PCINT13) PC2 (ADC11/CLKO/INT0/PCINT14) PC3 (RESET/dW/PCINT15) PC4 (XTAL2/PCINT16) (PCINT1/AIN0) PA1 (PCINT0/AREF) PA0 GND VCC PC5 (XTAL1/CLKI/PCINT17) (PCINT6/OC1B/ADC3) PA6 (PCINT5/OC0B/ADC2) PA5 (PCINT4/T0/ADC1) PA4 (PCINT3/T1/SNS/ADC0) PA3 (PCINT2/AIN1) PA2 20 19 18 17 16 PA7 (PCINT7/RXD0/ADC4) PB0 (PCINT8/TXD0/ADC5) PB1 (ADC6/DI/SDA/RXD1/PCINT9) PB2 (ADC7/DO/TXD1/PCINT10) PB3 (ADC8/OC1A/PCINT11) QFN/MLF ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 2 1.1 Pin Descriptions 1.1.1 VCC Supply voltage. 1.1.2 GND Ground. 1.1.3 XTAL1 Input to the inverting amplifier of the oscillator and the internal clock circuit. This is an alternative pin configuration of PC5. 1.1.4 XTAL2 Output from the inverting amplifier of the oscillator. Alternative pin configuration of PC4. 1.1.5 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 minimum pulse length is given in Table 24-5 on page 231. Shorter pulses are not guaranteed to generate a reset. The reset pin can also be used as a (weak) I/O pin. 1.1.6 Port A (PA7:PA0) This is an 8-bit, bi-directional I/O port with internal pull-up resistors (selected for each bit). Output buffers have the following drive characteristics: * PA7, PA4:PA0: Symmetrical, with standard sink and source capability * PA6, PA5: Asymmetrical, with high sink and standard source capability As inputs, port pins that are externally pulled low will source current provided that pull-up resistors are activated. Port pins are tri-stated when a reset condition becomes active, even if the clock is not running. This port has alternate pin functions to serve special features of the device. See "Alternate Functions of Port A" on page 62. 1.1.7 Port B (PB3:PB0) This is a 4-bit, bi-directional I/O port with internal pull-up resistors (selected for each bit).Output buffers have the following drive characteristics: * PB3: Asymmetrical, with high sink and standard source capability * PB2:PB0: Symmetrical, with standard sink and source capability As inputs, port pins that are externally pulled low will source current provided that pull-up resistors are activated. Port pins are tri-stated when a reset condition becomes active, even if the clock is not running. This port has alternate pin functions to serve special features of the device. See "Alternate Functions of Port B" on page 65. 1.1.8 Port C (PC5:PC0) This is a 6-bit, bi-directional I/O port with internal pull-up resistors (selected for each bit). Output buffers have the following drive characteristics: ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 3 * PC5:PC1: Symmetrical, with standard sink and source capability * PC0: Asymmetrical, with high sink and standard source capability As inputs, port pins that are externally pulled low will source current provided that pull-up resistors are activated. Port pins are tri-stated when a reset condition becomes active, even if the clock is not running. This port has alternate pin functions to serve special features of the device. See "Alternate Functions of Port C" on page 67. 2. Overview ATtiny1634 is a low-power CMOS 8-bit microcontrollers based on the AVR enhanced RISC architecture. By executing powerful instructions in a single clock cycle, the ATtiny1634 achieves throughputs approaching 1 MIPS per MHz allowing the system designer to optimize power consumption versus processing speed. Figure 2-1. Block Diagram VCC RESET GND ISP INTERFACE ON-CHIP DEBUGGER POWER SUPERVISION: POR BOD RESET DEBUG INTERFACE EEPROM CALIBRATED ULP OSCILLATOR CALIBRATED OSCILLATOR WATCHDOG TIMER TIMING AND CONTROL PROGRAM MEMORY DATA MEMORY (FLASH) (SRAM) 8-BIT TIMER/COUNTER 16-BIT TIMER/COUNTER USART0 USI USART1 TWO-WIRE INTERFACE TEMPERATURE SENSOR VOLTAGE REFERENCE ANALOG COMPARATOR MULTIPLEXER TOUCH SENSING ADC CPU CORE 8-BIT DATA BUS PORT A PORT B PORT C PA[7:0] PB[3:0] PC[5:0] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 4 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 a single instruction, executed in one clock cycle. The resulting architecture is compact and code efficient while achieving throughputs up to ten times faster than conventional CISC microcontrollers. ATtiny1634 provides the following features: * 16K bytes of in-system programmable Flash * 1K bytes of SRAM data memory * 256 bytes of EEPROM data memory * 18 general purpose I/O lines * 32 general purpose working registers * An 8-bit timer/counter with two PWM channels * A16-bit timer/counter with two PWM channels * Internal and external interrupts * A 10-bit ADC with 5 internal and 12 external channels * An ultra-low power, programmable watchdog timer with internal oscillator * Two programmable USART's with start frame detection * A slave Two-Wire Interface (TWI) * A Universal Serial Interface (USI) with start condition detector * A calibrated 8MHz oscillator * A calibrated 32kHz, ultra low power oscillator * Four software selectable power saving modes. The device includes the following modes for saving power: * Idle mode: stops the CPU while allowing the timer/counter, ADC, analog comparator, SPI, TWI, and interrupt system to continue functioning * ADC Noise Reduction mode: minimizes switching noise during ADC conversions by stopping the CPU and all I/O modules except the ADC * Power-down mode: registers keep their contents and all chip functions are disabled until the next interrupt or hardware reset * Standby mode: the 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 Flash program memory can be re-programmed in-system through a serial interface, by a conventional non-volatile memory programmer or by an on-chip boot code, running on the AVR core. The ATtiny1634 AVR is supported by a full suite of program and system development tools including: C compilers, macro assemblers, program debugger/simulators and evaluation kits. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 5 3. General Information 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.2 Code Examples This documentation contains simple code examples that briefly show how to use various parts of the device. These code examples assume that the part specific header file is included before compilation. Be aware that not all C compiler vendors include bit definitions in the header files and interrupt handling in C is compiler dependent. Please confirm with the C compiler documentation for more details. For I/O Registers located in the extended I/O map, "IN", "OUT", "SBIS", "SBIC", "CBI", and "SBI" instructions must be replaced with instructions that allow access to extended I/O. Typically, this means "LDS" and "STS" combined with "SBRS", "SBRC", "SBR", and "CBR". Note that not all AVR devices include an extended I/O map. 3.3 Capacitive Touch Sensing Atmel QTouch Library provides a simple to use solution for touch sensitive interfaces on Atmel AVR microcontrollers. The QTouch Library includes support for QTouch(R) and QMatrix(R) acquisition methods. Touch sensing is easily added to any application by linking the QTouch Library and using the Application Programming Interface (API) of the library to define the touch channels and sensors. The application then calls the API to retrieve channel information and determine the state of the touch sensor. The QTouch Library is free and can be downloaded from the Atmel website. For more information and details of implementation, refer to the QTouch Library User Guide - also available from the Atmel website. 3.4 Data Retention Reliability Qualification results show that the projected data retention failure rate is much less than 1 PPM over 20 years at 85C or 100 years at 25C. 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. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 6 Architectural Overview Figure 4-1. Block Diagram of the AVR Architecture 8-BIT DATA BUS INDIRECT ADDRESSING DATA MEMORY (SRAM) PROGRAM COUNTER PROGRAM MEMORY (FLASH) INSTRUCTION REGISTER INTERRUPT UNIT STATUS AND CONTROL GENERAL PURPOSE REGISTERS DIRECT ADDRESSING 4.1 X Y Z ALU INSTRUCTION DECODER CONTROL 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 instruction 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. 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 typical 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 operation, 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. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 7 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 position. The lower the Interrupt Vector address, the higher the priority. The I/O memory space contains 64 addresses for CPU peripheral functions as Control Registers, 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. In addition, the ATtiny1634 has Extended I/O Space from 0x60 - 0xFF in SRAM where only the ST/STS/STD and LD/LDS/LDD instructions can be used. 4.2 ALU - Arithmetic Logic Unit The high-performance AVR ALU operates in direct connection with all the 32 general purpose working registers. Within a single clock cycle, arithmetic operations between general purpose registers or between a register and an immediate are executed. The ALU operations are divided into three main categories - arithmetic, logical, and bitfunctions. Some implementations of the architecture also provide a powerful multiplier supporting both signed/unsigned multiplication and fractional format. See external document "AVR Instruction Set" and "Instruction Set Summary" on page 275 section for more information. 4.3 Status Register The Status Register contains information about the result of the most recently executed arithmetic instruction. This information can be used for altering program flow in order to perform conditional operations. Note that the Status Register is updated after all ALU operations. This will in many cases remove the need for using the dedicated compare instructions, resulting in faster and more compact code. See external document "AVR Instruction Set" and "Instruction Set Summary" on page 275 section for more information. 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. 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. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 8 Figure 4-2. General Purpose Working Registers 7 0 Addr. Special Function R0 0x00 R1 0x01 R2 0x02 R3 0x03 ... ... R12 0x0C R13 0x0D R14 0x0E R15 0x0F R16 0x10 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 implemented 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. 4.4.1 The X-register, Y-register, and Z-register The registers R26..R31 have added functions to their general purpose usage. These registers are 16-bit address pointers for indirect addressing of the data space. The three indirect address registers X, Y, and Z are defined as described in Figure 4-3 below. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 9 Figure 4-3. The X-, Y-, and Z-registers 15 X-register 7 0 XH 0 7 R27 XL R26 15 Y-register 7 0 YH 0 7 R29 YL 7 0 R28 15 Z-register 0 0 ZH R31 0 7 ZL 0 R30 In the different addressing modes these address registers have functions as fixed displacement, automatic increment, and automatic decrement (see the instruction set reference for details). 4.5 Stack Pointer The stack is mainly used for storing temporary data, local variables and return addresses after interrupts and subroutine calls. The Stack Pointer registers (SPH and SPL) always point to the top of the stack. Note that the stack grows from higher memory locations to lower memory locations. This means that the PUSH instructions decreases and the POP instruction increases the stack pointer value. The stack pointer points to the area of data memory where subroutine and interrupt stacks are located. This stack space must be defined by the program before any subroutine calls are executed or interrupts are enabled. The pointer is decremented by one when data is put on the stack with the PUSH instruction, and incremented by one when data is fetched with the POP instruction. It is decremented by two when the return address is put on the stack by a subroutine call or a jump to an interrupt service routine, and incremented by two when data is fetched by a return from subroutine (the RET instruction) or a return from interrupt service routine (the RETI instruction). The AVR stack pointer is typically implemented as two 8-bit registers in the I/O register file. The width of the stack pointer and the number of bits implemented is device dependent. In some AVR devices all data memory can be addressed using SPL, only. In this case, the SPH register is not implemented. The stack pointer must be set to point above the I/O register areas, the minimum value being the lowest address of SRAM. See Table 5-2 on page 16. 4.6 Instruction Execution Timing This section describes the general access timing concepts for instruction execution. The AVR CPU is driven by the CPU clock clkCPU, directly generated from the selected clock source for the chip. No internal clock division is used. Figure 4-4 shows the parallel instruction fetches and instruction executions enabled by the Harvard architecture and the fast access Register File concept. This is the basic pipelining concept to obtain up to 1 MIPS per MHz with the corresponding unique results for functions per cost, functions per clocks, and functions per power-unit. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 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 destination register. Figure 4-5. Single Cycle ALU Operation T1 T2 T3 T4 clkCPU Total Execution Time Register Operands Fetch ALU Operation Execute Result Write Back 4.7 Reset and Interrupt Handling The AVR provides several different interrupt sources. These interrupts and the separate Reset Vector each have a separate Program Vector in the Program memory space. All interrupts are assigned individual enable bits which must be written logic one together with the Global Interrupt Enable bit in the Status Register in order to enable the interrupt. The lowest addresses in the Program memory space are by default defined as the Reset and Interrupt Vectors. The complete list of vectors is shown in "Interrupts" on page 47. The list also determines the priority levels of the different interrupts. The lower the address the higher is the priority level. RESET has the highest priority, and next is INT0 - the External Interrupt Request 0. When an interrupt occurs, the Global Interrupt Enable I-bit is cleared and all interrupts are disabled. The user software can write logic one to the I-bit to enable nested interrupts. All enabled interrupts can then interrupt the current interrupt routine. The I-bit is automatically set when a Return from Interrupt instruction - RETI - is executed. There are basically two types of interrupts. The first type is triggered by an event that sets the Interrupt Flag. For these interrupts, the Program Counter is vectored to the actual Interrupt Vector in order to execute the interrupt handling routine, and hardware clears the corresponding Interrupt Flag. Interrupt Flags can also be cleared by writing a logic one to the flag bit position(s) 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. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 11 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. Assembly Code Example in r16, SREG cli ; store SREG value ; disable interrupts during timed sequence sbi EECR, EEMPE ; start EEPROM write sbi EECR, EEPE out SREG, r16 ; restore SREG value (I-bit) C Code Example char cSREG; cSREG = SREG; /* store SREG value */ /* disable interrupts during timed sequence */ _CLI(); EECR |= (1< 1MHz 12 - 22 pF Note Crystals, only. Not ceramic resonators. The oscillator can operate in different modes, each optimized for a specific frequency range. See Table 6-4 on page 31. Start-up time for this clock source is determined by the SUT bit, as shown in Table 6-2 on page 30. 6.2.5 Default Clock Settings The device is shipped with following fuse settings: * Calibrated Internal 8MHz Oscillator (see CKSEL bits on page 30) * Longest possible start-up time (see SUT bit on page 29) * System clock prescaler set to 8 (see CKDIV8 fuse bit on page 210) The default setting gives a 1MHz system clock and ensures all users can make their desired clock source setting using an in-system or high-voltage programmer. 6.3 System Clock Prescaler The ATtiny1634 system clock can be divided by setting the "CLKPR - Clock Prescale Register" on page 31. This feature can be used to decrease power consumption when the requirement for processing power is low. This can be used with all clock source options, and it will affect the clock frequency of the CPU and all synchronous peripherals. clkI/O, clkADC, clkCPU, and clkFLASH are divided by a factor as shown in Table 6-4 on page 31. 6.3.1 Switching Prescaler Setting When switching between prescaler settings, the System Clock Prescaler ensures that no glitch occurs in the clock system and that no intermediate frequency is higher than neither the clock frequency corresponding to the previous setting, nor the clock frequency corresponding to the new setting. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 28 The ripple counter that implements the prescaler runs at the frequency of the undivided clock, which may be faster than the CPU's clock frequency. Hence, it is not possible to determine the state of the prescaler - even if it were readable, and the exact time it takes to switch from one clock division to another cannot be exactly predicted. 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, 2 active clock edges are produced. Here, T1 is the previous clock period, and T2 is the period corresponding to the new prescaler setting. 6.4 Clock Output Buffer The device can output the system clock on the CLKO pin. To enable the output, the CKOUT_IO bit has to be programmed. The CKOUT fuse determines the initial value of the CKOUT_IO bit that is loaded to the CLKSR register when the device is powered up or has been reset. The clock output can be switched at run-time by setting the CKOUT_IO bit in CLKSR as described in chapter "CLKSR - Clock Setting Register" on page 29. This mode is suitable when the chip clock is used to drive other circuits on the system. Note that the clock will not be output during reset and that the normal operation of the I/O pin will be overridden when the fuse is programmed. Any clock source, including the internal oscillators, can be selected when the clock is output on CLKO. If the System Clock Prescaler is used, it is the divided system clock that is output. 6.5 Register Description 6.5.1 CLKSR - Clock Setting Register Bit 7 6 5 4 3 2 1 0 0x32 (0x52) OSCRDY CSTR CKOUT_IO SUT CKSEL3 CKSEL2 CKSEL1 CKSEL0 Read/Write R W R R R/W R/W R/W R/W Initial Value 0 0 0 CLKSR See Bit Description * Bit 7 - OSCRDY: Oscillator Ready This bit is set when oscillator time-out is complete. When OSCRDY is set the oscillator is stable and the clock source can be changed safely. * Bit 6 - CSTR: Clock Select Trigger This bit triggers the clock selection. It can be used to enable the oscillator in advance and select the clock source, before the oscillator is stable. If CSTR is set at the same time as the CKSEL bits are written, the contents are directly copied to the CKSEL register and the system clock is immediately switched. If CKSEL bits are written without setting CSTR, the oscillator selected by the CKSEL bits is enabled, but the system clock is not switched yet. * Bit 5 - CKOUT_IO: Clock Output This bit enables the clock output buffer. The CKOUT fuse determines the initial value of the CKOUT_IO bit that is loaded to the CLKSR register when the device is powered up or has been reset * Bit 4 - SUT: Start-Up Time The SUT and CKSEL bits define the start-up time of the device, as shown in Table 6-2, below. The initial value of the SUT bit is determined by the SUT fuse. The SUT fuse is loaded to the SUT bit when the device is powered up or has been reset. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 29 Table 6-2. Device Start-up Times SUT Clock From Power-Down (1)(2) From Reset (3) External 6 CK 22 CK + 16ms 0010 (4) Internal 8MHz 6 CK 20 CK + 16ms 0100 Internal 32kHz 6 CK 22 CK + 16ms CKSEL 0000 0001 0011 0101 ... 0111 0 (4) 1XX0 Ceramic resonator (5) 258 CK (6) 274 CK + 16ms 1XX1 Crystal oscillator 16K CK 16K CK + 16 ms 1K CK (7) 1K CK +16ms 0000 ... 0111 1XX1 1 1XX0 Note: Reserved Reserved Ceramic resonator 1. Device start-up time from power-down sleep mode. 2. When BOD has been disabled by software, the wake-up time from sleep mode will be approximately 60s to ensure the BOD is working correctly before MCU continues executing code. 3. Device start-up time after reset. 4. The device is shipped with this option selected. 5. This option is not suitable for use with crystals. 6. This option should not be used when operating close to the maximum frequency of the device, and only if frequency stability at start-up is not important for the application. 7. This option is intended for use with ceramic resonators and will ensure frequency stability at start-up. It can also be used with crystals when not operating close to the maximum frequency of the device, and if frequency stability at start-up is not important for the application. * Bits 3:0 - CKSEL[3:0]: Clock Select Bits These bits select the clock source of the system clock and can be written at run-time. The clock system ensures glitch free switching of the clock source. CKSEL fuses determine the initial value of the CKSEL bits when the device is powered up or reset. The clock alternatives are shown in Table 6-3 below. Table 6-3. CKSEL[3:0] Device Clocking Options (1) Frequency Device Clocking Option 0000 Any External Clock (see page 26) 0010 8MHz Calibrated Internal 8MHz Oscillator (see page 27) (2) 0100 32kHz Internal 32kHz Ultra Low Power (ULP) Oscillator (see page 27) 00X1 0101 ... 0111 -- 100X 0.4...0.9MHz 101X 0.9...3MHz 110X 3...8MHz 111X > 8MHz Reserved Crystal Oscillator / Ceramic Resonator (see page 27) ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 30 Note: 1. For all fuses "1" means unprogrammed and "0" means programmed. 2. This is the default setting. The device is shipped with this fuse combination. To avoid unintentional switching of clock source, a protected change sequence must be followed to change the CKSEL bits, as follows: 1. Write the signature for change enable of protected I/O register to register CCP. 2. Within four instruction cycles, write the CKSEL bits with the desired value. 6.5.2 CLKPR - Clock Prescale Register Bit 7 6 5 4 3 2 1 0 0x33 (0x53) - - - - CLKPS3 CLKPS2 CLKPS1 CLKPS0 Read/Write R R R R R/W R/W R/W R/W Initial Value 0 0 0 0 CLKPR See Bit Description * Bits 7:4 - Res: Reserved Bits These bits are reserved and will always read zero. * Bits 3:0 - CLKPS[3:0]: Clock Prescaler Select Bits 3 - 0 These bits define the division factor between the selected clock source and the internal system clock. These bits can be written run-time to vary the clock frequency to suit the application requirements. As the divider divides the master clock input to the MCU, the speed of all synchronous peripherals is reduced when a division factor is used. The division factors are given in Table 6-4 on page 31. To avoid unintentional changes of clock frequency, a protected change sequence must be followed to change the CLKPS bits: 1. Write the signature for change enable of protected I/O register to register CCP. 2. Within four instruction cycles, write the desired value to CLKPS bits. Interrupts must be disabled when changing prescaler setting to make sure the write procedure is not interrupted. Table 6-4. Clock Prescaler Select CLKPS3 CLKPS2 CLKPS1 CLKPS0 Clock Division Factor 0 0 0 0 1 (1) 0 0 0 1 2 0 0 1 0 4 0 0 1 1 8 (2) 0 1 0 0 16 0 1 0 1 32 0 1 1 0 64 0 1 1 1 128 1 0 0 0 256 ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 31 Table 6-4. Clock Prescaler Select (Continued) CLKPS3 CLKPS2 CLKPS1 CLKPS0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 Note: Clock Division Factor Reserved 1. This is the initial value when CKDIV8 fuse has been unprogrammed. 2. This is the initial value when CKDIV8 fuse has been programmed. The device is shipped with the CKDIV8 Fuse programmed. The initial value of clock prescaler bits is determined by the CKDIV8 fuse (see Table 22-5 on page 210). When CKDIV8 is unprogrammed, the system clock prescaler is set to one and, when programmed, to eight. Any value can be written to the CLKPS bits regardless of the CKDIV8 fuse bit setting. When CKDIV8 is programmed the initial value of CLKPS bits give a clock division factor of eight at start up. This is useful when the selected clock source has a higher frequency than allowed under present operating conditions. See "Speed" on page 229. 6.5.3 OSCCAL0 - Oscillator Calibration Register Bit (0x63) Read/Write Initial Value 7 6 5 4 3 2 1 0 CAL07 CAL06 CAL05 CAL04 CAL03 CAL02 CAL01 CAL00 R/W R/W R/W R/W R/W R/W R/W R/W OSCCAL0 Device Specific Calibration Value Although temperature slope and frequency are in part controlled by registers OSCTCAL0A and OSCTCAL0B it is possible to replace factory calibration by simply writing to this register alone. Optimal accuracy is achieved when OSCCAL0, OSCTAL0A and OSCTCAL0B are calibrated together. * Bits 7:0 - CAL0[7:0]: Oscillator Calibration Value The oscillator calibration register is used to trim the internal 8MHz oscillator and to remove process variations from the oscillator frequency. A pre-programmed calibration value is automatically written to this register during chip reset, giving the factory calibrated frequency specified in Table 24-2 on page 230. The application software can write this register to change the oscillator frequency. The oscillator can be calibrated to frequencies specified in Table 24-2 on page 230. Calibration outside that range is not guaranteed. The lowest oscillator frequency is reached by programming these bits to zero. Increasing the register value increases the oscillator frequency. A typical frequency response curve is shown in "Calibrated Oscillator Frequency (Nominal = 8MHz) vs. OSCCAL Value" on page 270. Note that this oscillator is used to time EEPROM and Flash write accesses, and write times will be affected accordingly. Do not calibrate to more than 8.8MHz if EEPROM or Flash is to be written. Otherwise, the EEPROM or Flash write may fail. To ensure stable operation of the MCU the calibration value should be changed in small steps. A step change in frequency of more than 2% from one cycle to the next can lead to unpredictable behavior. Also, the difference between two consecutive register values should not exceed 0x20. If these limits are exceeded the MCU must be kept in reset during changes to clock frequency. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 32 6.5.4 OSCTCAL0A - Oscillator Temperature Calibration Register A Bit 7 6 5 (0x64) Read/Write 4 3 2 1 0 R/W R/W Oscillator Temperature Calibration Data R/W R/W R/W Initial Value R/W R/W OSCTCAL0A R/W Device Specific Calibration Value This register is used for changing the temperature slope and frequency of the internal 8MHz oscillator. A pre-programmed calibration value is automatically written to this register during chip reset, giving the factory calibrated frequency specified in Table 24-2 on page 230. This register need not be updated if factory defaults in OSCCAL0 are overwritten although optimal accuracy is achieved when OSCCAL0, OSCTAL0A and OSCTCAL0B are calibrated together. * Bit 7 - Sign of Oscillator Temperature Calibration Value This is the sign bit of the calibration data. * Bits 6:0 - Oscillator Temperature Calibration Value These bits contain the numerical value of the calibration data. 6.5.5 OSCTCAL0B - Oscillator Temperature Calibration Register B Bit 7 6 5 (0x65) Read/Write 4 3 2 1 0 R/W R/W Oscillator Temperature Calibration Data R/W R/W Initial Value R/W R/W R/W OSCTCAL0B R/W Device Specific Calibration Value A pre-programmed calibration value is automatically written to this register during chip reset, giving the factory calibrated frequency specified in Table 24-2 on page 230. This register need not be updated if factory defaults in OSCCAL0 are overwritten although optimal accuracy is achieved when OSCCAL0, OSCTAL0A and OSCTCAL0B are calibrated together. * Bit 7 - Temperature Compensation Enable When this bit is set the contents of registers OSCTCAL0A and OSCTCAL0B are used for calibration. When this bit is cleared the temperature compensation hardware is disabled and registers OSCTCAL0A and OSCTCAL0B have no effect on the frequency of the internal 8MHz oscillator. Note that temperature compensation has a large effect on oscillator frequency and, hence, when enabled or disabled the OSCCAL0 register must also be adjusted to compensate for this effect. * Bits 6:0 - Temperature Compensation Step Adjust These bits control the step size of the calibration data in OSCTCAL0A. The largest step size is achieved for 0x00 and smallest step size for 0x7F. 6.5.6 OSCCAL1 - Oscillator Calibration Register Bit 7 6 5 4 3 2 1 0 (0x66) - - - - - - CAL11 CAL10 Read/Write R R R R R R R/W R/W Initial Value OSCCAL1 Device Specific Calibration Value * Bits 7:2 - Res: Reserved Bits These bits are reserved and will always read zero. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 33 * Bits 1:0 - CAL1[1:0]: Oscillator Calibration Value The oscillator calibration register is used to trim the internal 32kHz oscillator and to remove process variations from the oscillator frequency. A pre-programmed calibration value is automatically written to this register during chip reset, giving the factory calibrated frequency as specified in Table 24-3 on page 231. The application software can write this register to change the oscillator frequency. The oscillator can be calibrated to frequencies as specified in Table 24-3 on page 231. Calibration outside that range is not guaranteed. The lowest oscillator frequency is reached by programming these bits to zero. Increasing the register value increases the oscillator frequency. 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. Sleep Modes Figure 6-1 on page 25 presents the different clock systems and their distribution in ATtiny1634. The figure is helpful in selecting an appropriate sleep mode. Table 7-1 shows the different sleep modes and the sources that may be used for wake up. Active Clock Domains and Wake-up Sources in Different Sleep Modes Note: USI TWI Slave Other I/O Power-down USART X ADC Interrupt Standby SPM/EEPROM Ready Interrupt X INT0 and Pin Change ADC Noise Reduction Watchdog Interrupt X clkADC Idle Wake-up Sources clkIO Sleep Mode Active Clock Domains clkFLASH Oscillators clkCPU Table 7-1. Main Clock Source Enabled 7.1 X X X X X X X X X X X X X (4) X X X X (4) X (1) X (2) X (3) X X (4) X (1) X (2) X (3) X (1) X (2) X (3) 1. Start frame detection, only. 2. Start condition, only. 3. Address match interrupt, only. 4. For INT0 level interrupt, only. To enter a sleep mode, the SE bit in MCUCR must be set and a SLEEP instruction must be executed. The SMn bits in MCUCR select which sleep mode will be activated by the SLEEP instruction. See Table 7-2 on page 37 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. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 34 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 48 for details. 7.1.1 Idle Mode This sleep mode basically halts clkCPU and clkFLASH, while allowing other clocks to run. In Idle Mode, the CPU is stopped but the following peripherals continue to operate: * Watchdog and interrupt system * Analog comparator, and ADC * USART, TWI, and timer/counters Idle mode allows the MCU to wake up from external triggered interrupts as well as internal ones, such as 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 ACSRA. See "ACSRA - Analog Comparator Control and Status Register" on page 182. This will reduce power consumption in Idle mode. If the ADC is enabled, a conversion starts automatically when this mode is entered. 7.1.2 ADC Noise Reduction Mode This sleep mode halts clkI/O, clkCPU, and clkFLASH, while allowing other clocks to run. In ADC Noise Reduction mode, the CPU is stopped but the following peripherals continue to operate: * Watchdog (if enabled), and external interrupts * ADC * USART start frame detector, and TWI This improves the noise environment for the ADC, enabling higher resolution measurements. If the ADC is enabled, a conversion starts automatically when this mode is entered. The following events can wake up the MCU: * Watchdog reset, external reset, and brown-out reset * External level interrupt on INT0, and pin change interrupt * ADC conversion complete interrupt, and SPM/EEPROM ready interrupt * USI start condition, USART start frame detection, and TWI address match 7.1.3 Power-Down Mode This sleep mode halts all generated clocks, allowing operation of asynchronous modules, only. In Power-down Mode the oscillator is stopped, while the following peripherals continue to operate: * Watchdog (if enabled), external interrupts The following events can wake up the MCU: * Watchdog reset, external reset, and brown-out reset * External level interrupt on INT0, and pin change interrupt * USI start condition, USART start frame detection, and TWI address match ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 35 7.1.4 Standby Mode Standby Mode is identical to power-down, with the exception that the oscillator is kept running. From Standby mode, the device wakes up in six clock cycles. 7.2 Power Reduction Register The Power Reduction Register (PRR), see "PRR - Power Reduction Register" on page 38, provides a method to reduce power consumption by stopping the clock to individual peripherals. When the clock for a peripheral is stopped then: * The current state of the peripheral is frozen. * The associated registers can not be read or written. * Resources used by the peripheral will remain occupied. The peripheral should in most cases be disabled before stopping the clock. Clearing the PRR bit wakes up the peripheral and puts it in the same state as before shutdown. Peripheral shutdown can be used in Idle mode and Active mode to significantly reduce the overall power consumption. In all other sleep modes, the clock is already stopped. 7.3 Minimizing Power Consumption There are several issues to consider when trying to minimize the power consumption in an AVR controlled system. In general, sleep modes should be used as much as possible, and the sleep mode should be selected so that as few as possible of the device's functions are operating. All functions not needed should be disabled. In particular, the following modules may need special consideration when trying to achieve the lowest possible power consumption. 7.3.1 Analog to Digital Converter If enabled, the ADC will be enabled in all sleep modes. To save power, the ADC should be disabled before entering any sleep mode. When the ADC is turned off and on again, the next conversion will be an extended conversion. See "Analog to Digital Converter" on page 185 for details on ADC operation. 7.3.2 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 disabled in all sleep modes. Otherwise, the Internal Voltage Reference will be enabled, independent of sleep mode. See "Analog Comparator" on page 181 for details on how to configure the Analog Comparator. 7.3.3 Brown-out Detector If the Brown-out Detector is not needed in the application, this module should be turned off. If the Brown-out Detector is enabled by the BODPD Fuses, it will be enabled in all sleep modes, and hence, always consume power. In the deeper sleep modes, this will contribute significantly to the total current consumption. If the Brown-out Detector is needed in the application, this module can also be set to Sampled BOD mode to save power. See "Brown-Out Detection" on page 41 for details on how to configure the Brown-out Detector. 7.3.4 Internal Voltage Reference The Internal Voltage Reference will be enabled when needed by the Brown-out Detection, the Analog Comparator or the ADC. If these modules are disabled as described in the sections above, the internal voltage reference will be disabled and it will not be consuming power. When turned on again, the user must allow the reference to start up ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 36 before the output is used. If the reference is kept on in sleep mode, the output can be used immediately. See Internal Bandgap Reference in Table 24-5 on page 231 for details on the start-up time. 7.3.5 Watchdog Timer If the Watchdog Timer is not needed in the application, this module should be turned off. If the Watchdog Timer is enabled, it will be enabled in all sleep modes, and hence, always consume power. In the deeper sleep modes, this will contribute to the total current consumption. See "Watchdog Timer" on page 43 for details on how to configure the Watchdog Timer. 7.3.6 Port Pins When entering a sleep mode, all port pins should be configured to use minimum power. The most important thing is then to ensure that no pins drive resistive loads. In sleep modes where both the I/O clock (clkI/O) and the ADC clock (clkADC) are stopped, the input buffers of the device will be disabled. This ensures that no power is consumed by the input logic when not needed. In some cases, the input logic is needed for detecting wake-up conditions, and it will then be enabled. See the section "Digital Input Enable and Sleep Modes" on page 58 for details on which pins are enabled. If the input buffer is enabled and the input signal is left floating or has an analog signal level close to VCC/2, the input buffer will use excessive power. For analog input pins, the digital input buffer should be disabled at all times. An analog signal level close to VCC/2 on an input pin can cause significant current even in active mode. Digital input buffers can be disabled by writing to the Digital Input Disable Register (DIDR0). See "DIDR0 - Digital Input Disable Register 0" on page 200 for details. 7.3.7 On-chip Debug System If the On-chip debug system is enabled by the DWEN Fuse and the chip enters sleep mode, the main clock source is enabled and hence always consumes power. In the deeper sleep modes, this will contribute significantly to the total current consumption. 7.4 Register Description 7.4.1 MCUCR - MCU Control Register The MCU Control Register contains control bits for power management. Bit 7 6 5 4 3 2 1 0 0x36 (0x56) - SM1 SM0 SE - - ISC01 ISC00 Read/Write R R/W R/W R/W R R R/W R/W Initial Value 0 0 0 0 0 0 0 0 MCUCR * Bits 7, 3:2 - Res: Reserved Bits These bits are reserved and will always read zero. * Bits 6:5 - SM[1:0]: Sleep Mode Select Bits 1 and 0 These bits select between available sleep modes, as shown in Table 7-2. Table 7-2. Sleep Mode Select SM1 SM0 Sleep Mode 0 0 Idle 0 1 ADC Noise Reduction 1 0 Power-down 1 1 Standby(1) ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 37 Note: 1. Only recommended with external crystal or resonator selected as clock source * Bit 4 - SE: Sleep Enable The SE bit must be written to logic one to make the MCU enter the sleep mode when the SLEEP instruction is executed. To avoid the MCU entering the sleep mode unless it is the programmer's purpose, it is recommended to write the Sleep Enable (SE) bit to one just before the execution of the SLEEP instruction and to clear it immediately after waking up. 7.4.2 PRR - Power Reduction Register The Power Reduction Register provides a method to reduce power consumption by allowing peripheral clock signals to be disabled. Bit 7 6 5 4 3 2 1 0 0x34 (0x54) - PRTWI PRTIM1 PRTIM0 PRUSI PRUSART1 PRUSART0 PRADC Read/Write R R/W R/W R/W R/W R/W R/W R/W Initial Value 0 0 0 0 0 0 0 0 PRR * Bit 7 - Res: Reserved Bit This bit is a reserved bit and will always read zero. * Bit 6 - PRTWI: Power Reduction Two-Wire Interface Writing a logic one to this bit shuts down the Two-Wire Interface module. * Bit 5 - PRTIM1: Power Reduction Timer/Counter1 Writing a logic one to this bit shuts down the Timer/Counter1 module. When the Timer/Counter1 is enabled, operation will continue like before the shutdown. * Bit 4 - 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. * Bit 3 - PRUSI: Power Reduction USI Writing a logic one to this bit shuts down the USI by stopping the clock to the module. When waking up the USI again, the USI should be re initialized to ensure proper operation. * Bit 2 - PRUSART1: Power Reduction USART1 Writing a logic one to this bit shuts down the USART1 module. When the USART1 is enabled, operation will continue like before the shutdown. * Bit 1 - PRUSART0: Power Reduction USART0 Writing a logic one to this bit shuts down the USART0 module. When the USART0 is enabled, operation will continue like before the shutdown. * Bit 0 - PRADC: Power Reduction ADC Writing a logic one to this bit shuts down the ADC. The ADC must be disabled before shut down. The analog comparator cannot be used when the ADC is shut down. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 38 8. System Control and Reset 8.1 Resetting the AVR During reset, all I/O registers are set to their initial values, and the program starts execution from the Reset Vector. The instruction placed at the Reset Vector should be a JMP (two-word, direct jump) instruction to the reset handling routine, although other one- or two-word jump instructions can be used. If the program never enables an interrupt source, the interrupt vectors are not used, and regular program code can be placed at these locations. The circuit diagram in Figure 8-1 shows the reset logic. Electrical parameters of the reset circuitry are defined in section "System and Reset" on page 231. Figure 8-1. Reset Logic DATA BUS PULL-UP RESISTOR WDRF EXTRF BORF BROWN OUT RESET CIRCUIT VCC RESET PORF RESET FLAG REGISTER (RSTFLR) BODLEVEL2...0 S POWER-ON RESET CIRCUIT COUNTER RESET TIMEOUT SPIKE FILTER EXTERNAL RESET CIRCUIT Q INTERNAL RESET R DELAY COUNTERS CK WATCHDOG TIMER RSTDISBL WATCHDOG OSCILLATOR CLOCK GENERATOR 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. 8.2 Reset Sources The ATtiny1634 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 when RESET function is enabled * 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 8.2.1 Power-on Reset A Power-on Reset (POR) pulse is generated by an on-chip detection circuit. The detection level is defined in "System and Reset" on page 231. The POR is activated whenever VCC is below the detection level. The POR circuit can be used to trigger the Start-up Reset, as well as to detect a failure in supply voltage. A Power-on Reset (POR) circuit ensures that the device is reset from Power-on. Reaching the Power-on Reset threshold voltage invokes the delay counter, which determines how long the device is kept in reset after VCC rise. The reset signal is activated again, without any delay, when VCC decreases below the detection level. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 39 Figure 8-2. MCU Start-up, RESET Tied to VCC V CC V POT RESET V RST TIME-OUT t TOUT INTERNAL RESET Figure 8-3. MCU Start-up, RESET Extended Externally V CC V POT > t TOUT RESET TIME-OUT V RST t TOUT INTERNAL RESET 8.2.2 External Reset An External Reset is generated by a low level on the RESET pin if enabled. Reset pulses longer than the minimum pulse width (see section "System and Reset" on page 231) will generate a reset, even if the clock is not running. Shorter pulses are not guaranteed to generate a reset. When the applied signal reaches the Reset Threshold Voltage - VRST - on its positive edge, the delay counter starts the MCU after the time-out period - tTOUT - has expired. External reset is ignored during Power-on start-up count. After Power-on reset the internal reset is extended only if RESET pin is low when the initial Power-on delay count is complete. See Figure 8-2 and Figure 8-3. Figure 8-4. External Reset During Operation CC ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 40 8.2.3 Watchdog Reset When the Watchdog times out, it will generate a short reset pulse. On the falling edge of this pulse, the delay timer starts counting the time-out period tTOUT. See page 43 for details on operation of the Watchdog Timer and Table 24-5 on page 231 for details on reset time-out. Figure 8-5. Watchdog Reset During Operation CC CK 8.2.4 Brown-Out Detection The Brown-Out Detection (BOD) circuit monitors that the VCC level is kept above a configurable trigger level, VBOT. When the BOD is enabled, a BOD reset will be given when VCC falls and remains below the trigger level for the length of the detection time, tBOD. The reset is kept active until VCC again rises above the trigger level. Figure 8-6. Brown-out Detection reset. tBOD VCC VBOT- TIME-OUT VBOT+ tTOUT INTERNAL RESET The BOD circuit will not detect a drop in VCC unless the voltage stays below the trigger level for the detection time, tBOD (see "System and Reset" on page 231). The BOD circuit has three modes of operation: * Disabled: In this mode of operation VCC is not monitored and, hence, it is recommended only for applications where the power supply remains stable. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 41 * Enabled: In this mode the VCC level is continuously monitored. If VCC drops below VBOT for at least tBOD a brown-out reset will be generated. * Sampled: In this mode the VCC level is sampled on each negative edge of a 1kHz clock that has been derived from the 32kHz ULP oscillator. Between each sample the BOD is turned off. Compared to the mode where BOD is constantly enabled this mode of operation reduces power consumption but fails to detect drops in VCC between two positive edges of the 1kHz clock. When a brown-out is detected in this mode, the BOD circuit is set to enabled mode to ensure that the device is kept in reset until VCC has risen above VBOT . The BOD will return to sampled mode after reset has been released and the fuses have been read in. The BOD mode of operation is selected using BODACT and BODPD fuse bits. The BODACT fuse bits determine how the BOD operates in active and idle mode, as shown in Table 8-1. Table 8-1. Setting BOD Mode of Operation in Active and Idle Modes BODACT1 BODACT0 Mode of Operation 0 0 Reserved 0 1 Sampled 1 0 Enabled 1 1 Disabled The BODPD fuse bits determine the mode of operation in all sleep modes except idle mode, as shown in Table 82. Table 8-2. Setting BOD Mode of Operation in Sleep Modes Other Than Idle BODPD1 BODPD0 Mode of Operation 0 0 Reserved 0 1 Sampled 1 0 Enabled 1 1 Disabled See "Fuse Bits" on page 209. 8.3 Internal Voltage Reference ATtiny1634 features an internal bandgap reference. This reference is used for Brown-out Detection, and it can be used as an input to the Analog Comparator or the ADC. The bandgap voltage varies with supply voltage and temperature. 8.3.1 Voltage Reference Enable Signals and Start-up Time The voltage reference has a start-up time that may influence the way it should be used. The start-up time is given in "System and Reset" on page 231. To save power, the reference is not always turned on. The reference is on during the following situations: 1. When the BOD is enabled (see "Brown-Out Detection" on page 41). 2. When the internal reference is connected to the Analog Comparator (by setting the ACBG bit in ACSRA). 3. When the ADC is enabled. 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 conATtiny1634 [DATASHEET] 8303G-AVR-11/2013 42 sumption 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. 8.4 Watchdog Timer The Watchdog Timer is clocked from the internal 32kHz ultra low power oscillator (see page 27). By controlling the Watchdog Timer prescaler, the Watchdog Reset interval can be adjusted as shown in Table 8-5 on page 46. The WDR - Watchdog Reset - instruction resets the Watchdog Timer. The Watchdog Timer is also reset when it is disabled and when a Chip Reset occurs. Ten different clock cycle periods can be selected to determine the reset period. If the reset period expires without another Watchdog Reset, the ATtiny1634 resets and executes from the Reset Vector. For timing details on the Watchdog Reset, refer to Table 8-5 on page 46. 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-3 See "Timed Sequences for Changing the Configuration of the Watchdog Timer" on page 43 for details. Table 8-3. WDT Configuration as a Function of the Fuse Settings of WDTON Safety Level WDTON WDT Initial State How to Disable the WDT How to Change Timeout Unprogrammed 1 Disabled Timed sequence No limitations Programmed 2 Enabled Always enabled Timed sequence Watchdog Timer WDP0 WDP1 WDP2 WDP3 OSC/256K OSC/64K OSC/128K OSC/32K OSC/8K OSC/2K OSC/1K OSC/512 WATCHDOG RESET OSC/16K WATCHDOG PRESCALER 32 kHz ULP OSCILLATOR OSC/4K Figure 8-7. MUX WDE MCU RESET 8.4.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. * Safety Level 1 In this mode, the Watchdog Timer is initially disabled, but can be enabled by writing the WDE bit to one without any restriction. A timed sequence is needed when disabling an enabled Watchdog Timer. To disable an enabled Watchdog Timer, the following procedure must be followed: ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 43 a. Write the signature for change enable of protected I/O registers to register CCP b. Within four instruction cycles, in the same operation, write WDE and WDP bits * Safety Level 2 In this mode, the Watchdog Timer is always enabled, and the WDE bit will always read as one. A timed sequence is needed when changing the Watchdog Time-out period. To change the Watchdog Time-out, the following procedure must be followed: a. Write the signature for change enable of protected I/O registers to register CCP b. Within four instruction cycles, write the WDP bit. The value written to WDE is irrelevant 8.4.2 Code Examples The following code example shows how to turn off the WDT. The example assumes that interrupts are controlled (e.g., by disabling interrupts globally) so that no interrupts will occur during execution of these functions. Assembly Code Example WDT_off: wdr ; Clear WDRF in RSTFLR in andi out r16, RSTFLR r16, ~(1< ; Main program start ; Address 0x0038 ... Note: 9.2 See "Code Examples" on page 6. External Interrupts External Interrupts are triggered by the INT0 pin, or by any of the PCINTn pins. Note that, if enabled, the interrupts will trigger even if the INTn or PCINTn pins are configured as outputs. This feature provides a way of generating software interrupts. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 48 The pin change interrupts trigger as follows: * Pin Change Interrupt 0 (PCI0): triggers if any enabled PCINT[7:0] pin toggles * Pin Change Interrupt 1 (PCI1): triggers if any enabled PCINT[11:8] pin toggles * Pin Change Interrupt 2 (PCI2): triggers if any enabled PCINT[17:12] pin toggles Registers PCMSK0, PCMSK1, and PCMSK2 control which pins contribute to the pin change interrupts. Pin change interrupts on PCINT[17:0] are detected asynchronously, which means that these interrupts can be used for waking the part also from sleep modes other than Idle mode. External interrupt INT0 can be triggered by a falling or rising edge, or a low level. See "MCUCR - MCU Control Register" on page 37. When INT0 is enabled and configured as level triggered, the interrupt will trigger as long as the pin is held low. Note that recognition of falling or rising edge interrupts on INT0 requires the presence of an I/O clock, as described in "Clock System" on page 24. 9.2.1 Low Level Interrupt A low level interrupt on INT0 is detected asynchronously. This means that the interrupt source can be used for waking the part also from sleep modes other than Idle (the I/O clock is halted in all sleep modes except Idle). Note that if a level triggered interrupt is used for wake-up from Power-down, the required level must be held long enough for the MCU to complete the wake-up to trigger the level interrupt. If the level disappears before the end of the Start-up Time, the MCU will still wake up, but no interrupt 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 following the SLEEP command. 9.2.2 Pin Change Interrupt Timing A timing example of a pin change interrupt is shown in Figure 9-1. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 49 Figure 9-1. Timing of pin change interrupts pin_lat PCINT(0) LE clk D pcint_in_(0) Q pin_sync PCINT(0) in PCMSK(x) 0 pcint_syn pcint_setflag PCIF x clk clk PCINT(0) pin_lat pin_sync pcint_in_(0) pcint_syn pcint_setflag PCIF ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 50 9.3 9.3.1 Register Description MCUCR - MCU Control Register Bit 7 6 5 4 3 2 1 0 0x36 (0x56) - SM1 SM0 SE - - ISC01 ISC00 Read/Write R R/W R/W R/W R R R/W R/W Initial Value 0 0 0 0 0 0 0 0 MCUCR * Bits 1:0 - ISC0[1:0]: Interrupt Sense Control 0 Bit 1 and Bit 0 External Interrupt 0 is triggered by activity on pin INT0, provided that the SREG I-flag and the corresponding interrupt mask are set. The conditions required to trigger the interrupt are defined in Table 9-2. Table 9-2. External Interrupt 0 Sense Control ISC01 ISC00 0 0 The low level of INT0 generates an interrupt request (1) 0 1 Any logical change on INT0 generates an interrupt request (2) 1 0 The falling edge of INT0 generates an interrupt request (2) 1 1 The rising edge of INT0 generates an interrupt request (2) Note: Description 1. If low level interrupt is selected, the low level must be held until the completion of the currently executing instruction to generate an interrupt. 2. The value on the INT0 pin is sampled before detecting edges. If edge or toggle interrupt is selected, pulses that last longer than one clock period will generate an interrupt. Shorter pulses are not guaranteed to generate an interrupt. 9.3.2 GIMSK - General Interrupt Mask Register Bit 7 6 5 4 3 2 1 0x3C (0x5C) - INT0 PCIE2 PCIE1 PCIE0 - - 0 - Read/Write R R/W R/W R/W R/W R R R Initial Value 0 0 0 0 0 0 0 0 GIMSK * Bits 7, 2:0 - Res: Reserved Bits These bits are reserved and will always read zero. * Bit 6 - INT0: External Interrupt Request 0 Enable The external interrupt for pin INT0 is enabled when this bit and the I-bit in the Status Register (SREG) are set. The trigger conditions are set with the ISC0n bits. Activity on the pin will cause an interrupt request even if INT0 has been configured as an output. * Bit 5 - PCIE2: Pin Change Interrupt Enable 2 When this bit and the I-bit of SREG are set the Pin Change Interrupt 2 is enabled. Any change on an enabled PCINT[17:12] pin will cause a PCINT2 interrupt. See Table 9-1 on page 47. Each pin can be individually enabled. See "PCMSK2 - Pin Change Mask Register 2" on page 52. * Bit 4 - PCIE1: Pin Change Interrupt Enable 1 When this bit and the I-bit of SREG are set the Pin Change Interrupt 1 is enabled. Any change on an enabled PCINT[11:8] pin will cause a PCINT1 interrupt. See Table 9-1 on page 47. Each pin can be individually enabled. See "PCMSK1 - Pin Change Mask Register 1" on page 53. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 51 * Bit 3 - PCIE0: Pin Change Interrupt Enable 0 When this bit and the I-bit of SREG are set the Pin Change Interrupt 0 is enabled. Any change on an enabled PCINT[7:0] pin will cause a PCINT0 interrupt. See Table 9-1 on page 47. Each pin can be individually enabled. See "PCMSK0 - Pin Change Mask Register 0" on page 53. 9.3.3 GIFR - General Interrupt Flag Register Bit 7 6 5 4 3 2 1 0x3B (0x5B) - INTF0 PCIF2 PCIF1 PCIF0 - - 0 - Read/Write R R/W R/W R/W R/W R R R Initial Value 0 0 0 0 0 0 0 0 GIFR * Bits 7, 2:0 - Res: Reserved Bits These bits are reserved and will always read as zero. * Bit 6 - INTF0: External Interrupt Flag 0 This bit is set when activity on INT0 has triggered an interrupt request. Provided that the I-bit in SREG and the INT0 bit in GIMSK are set, the MCU will jump to the corresponding interrupt vector. The flag is cleared when the interrupt service routine is executed. Alternatively, the flag can be cleared by writing a logical one to it. This flag is always cleared when INT0 is configured as a level interrupt. * Bit 5 - PCIF2: Pin Change Interrupt Flag 2 This bit is set when a logic change on any PCINT[17:12] pin has triggered an interrupt request. Provided that the Ibit in SREG and the PCIE2 bit in GIMSK are set, the MCU will jump to the corresponding interrupt vector. The flag is cleared when the interrupt routine is executed. Alternatively, the flag can be cleared by writing a logical one to it. * Bit 4 - PCIF1: Pin Change Interrupt Flag 1 This bit is set when a logic change on any PCINT[11:8] pin has triggered an interrupt request. Provided that the Ibit in SREG and the PCIE1 bit in GIMSK are set, the MCU will jump to the corresponding interrupt vector. The flag is cleared when the interrupt routine is executed. Alternatively, the flag can be cleared by writing a logical one to it. * Bit 3 - PCIF0: Pin Change Interrupt Flag 0 This bit is set when a logic change on any PCINT[7:0] pin has triggered an interrupt request. Provided that the I-bit in SREG and the PCIE0 bit in GIMSK are set, the MCU will jump to the corresponding interrupt vector. The flag is cleared when the interrupt routine is executed. Alternatively, the flag can be cleared by writing a logical one to it. 9.3.4 PCMSK2 - Pin Change Mask Register 2 Bit 7 6 5 4 3 2 1 0 0x29 (0x49) - - PCINT17 PCINT16 PCINT15 PCINT14 PCINT13 PCINT12 Read/Write R R R/W R/W R/W R/W R/W R/W Initial Value 0 0 0 0 0 0 0 0 PCMSK2 * Bits 7:6 - Res: Reserved Bits These bits are reserved and will always read zero. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 52 * Bits 5:0 - PCINT[17:12]: Pin Change Enable Mask 17:12 Each PCINTn bit selects if the pin change interrupt of the corresponding I/O pin is enabled. Pin change interrupt on a pin is enabled by setting the mask bit for the pin (PCINTn) and the corresponding group bit (PCIEn) in GIMSK. When this bit is cleared the pin change interrupt on the corresponding pin is disabled. 9.3.5 PCMSK1 - Pin Change Mask Register 1 Bit 7 6 5 4 3 2 1 0 0x28 (0x48) - - - - PCINT11 PCINT10 PCINT9 PCINT8 Read/Write R R R R R/W R/W R/W R/W Initial Value 0 0 0 0 0 0 0 0 PCMSK1 * Bits 7:4 - Res: Reserved Bits These bits are reserved and will always read zero. * Bits 3:0 - PCINT[11:8]: Pin Change Enable Mask 11:8 Each PCINTn bit selects if the pin change interrupt of the corresponding I/O pin is enabled. Pin change interrupt on a pin is enabled by setting the mask bit for the pin (PCINTn) and the corresponding group bit (PCIEn) in GIMSK. When this bit is cleared the pin change interrupt on the corresponding pin is disabled. 9.3.6 PCMSK0 - Pin Change Mask Register 0 Bit 7 6 5 4 3 2 1 0 0x27 (0x47) PCINT7 PCINT6 PCINT5 PCINT4 PCINT3 PCINT2 PCINT1 PCINT0 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 PCMSK0 * Bits 7:0 - PCINT[7:0]: Pin Change Enable Mask 7:0 Each PCINTn bit selects if the pin change interrupt of the corresponding I/O pin is enabled. Pin change interrupt on a pin is enabled by setting the mask bit for the pin (PCINTn) and the corresponding group bit (PCIEn) in GIMSK. When this bit is cleared the pin change interrupt on the corresponding pin is disabled. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 53 10. I/O Ports 10.1 Overview All AVR ports have true Read-Modify-Write functionality when used as general digital I/O ports. This means that the direction of one port pin can be changed without unintentionally changing the direction of any other pin with the SBI and CBI instructions. The same applies when changing drive value (if configured as output) or enabling/disabling of pull-up resistors (if configured as input). Most output buffers have symmetrical drive characteristics with both high sink and source capability, while some are asymmetrical and have high sink and standard source capability. The pin driver is strong enough to drive LED displays directly. All port pins have individually selectable pull-up resistors with a supply-voltage invariant resistance. All I/O pins have protection diodes to both VCC and Ground as indicated in Figure 10-1 on page 54. See "Electrical Characteristics" on page 228 for a complete list of parameters. Figure 10-1. I/O Pin Equivalent Schematic Rpu Logic Pxn 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" represents 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 Registers and bit locations are listed in "" on page 70. Four I/O memory address locations are allocated for each port, one each for the Data Register - PORTx, Data Direction Register - DDRx, Pull-up Enable Register - PUEx, and the Port Input Pins - PINx. The Port Input Pins I/O location is read only, while the Data Register, the Data Direction Register, and the Pull-Up Enable Register are read/write. However, writing a logic one to a bit in the PINx Register, will result in a toggle in the corresponding bit in the Data Register. Using the I/O port as General Digital I/O is described in "Ports as General Digital I/O" on page 54. 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 59. Refer to the individual module sections for a full description of the alternate 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. 10.2 Ports as General Digital I/O The ports are bi-directional I/O ports with optional internal pull-ups. Figure 10-2 shows a functional description of one I/O-port pin, here generically called Pxn. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 54 Figure 10-2. General Digital I/O(1) REx Q D PUExn Q CLR RESET Q WEx D DDxn Q CLR WDx RESET DATA BUS RDx 1 Q Pxn D 0 PORTxn Q CLR RESET WRx WPx RRx SLEEP SYNCHRONIZER D Q L Q D RPx Q PINxn Q clk I/O SLEEP: clkI/O: Note: 10.2.1 SLEEP CONTROL I/O CLOCK WEx: REx: WDx: RDx: WRx: RRx: RPx: WPx: WRITE PUEx READ PUEx WRITE DDRx READ DDRx WRITE PORTx READ PORTx REGISTER READ PORTx PIN WRITE PINx REGISTER 1. WEx, WRx, WPx, WDx, REx, RRx, RPx, and RDx are common to all pins within the same port. clkI/O, and SLEEP are common to all ports. Configuring the Pin Each port pin consists of four register bits: DDxn, PORTxn, PUExn, and PINxn. As shown in "Register Description" on page 71, the DDxn bits are accessed at the DDRx I/O address, the PORTxn bits at the PORTx I/O address, the PUExn bits at the PUEx I/O address, and the PINxn bits at the PINx I/O address. The DDxn bit in the DDRx Register selects the direction of this pin. If DDxn is written logic one, Pxn is configured as an output pin. If DDxn is written logic zero, Pxn is configured as an input pin. 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). ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 55 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. Table 10-1 summarizes the control signals for the pin value. Table 10-1. Port Pin Configurations DDxn PORTxn PUExn I/O Pull-up Comment 0 X 0 Input No Tri-state (hi-Z) 0 X 1 Input Yes Sources current if pulled low externally 1 0 0 Output No Output low (sink) 1 0 1 Output Yes NOT RECOMMENDED. Output low (sink) and internal pull-up active. Sources current through the internal pull-up resistor and consumes power constantly 1 1 0 Output No Output high (source) 1 1 1 Output Yes Output high (source) and internal pull-up active Port pins are tri-stated when a reset condition becomes active, even when no clocks are running. 10.2.2 Toggling the Pin Writing a logic one to PINxn toggles the value of PORTxn, independent on the value of DDRxn. Note that the SBI instruction can be used to toggle one single bit in a port. 10.2.3 Break-Before-Make Switching In Break-Before-Make mode, switching the DDRxn bit from input to output introduces an immediate tri-state period lasting one system clock cycle, as indicated in Figure 10-3. For example, if the system clock is 4MHz and the DDRxn is written to make an output, an immediate tri-state period of 250 ns is introduced before the value of PORTxn is seen on the port pin. To avoid glitches it is recommended that the maximum DDRxn toggle frequency is two system clock cycles. The Break-Before-Make mode applies to the entire port and it is activated by the BBMx bit. For more details, see "PORTCR - Port Control Register" on page 71. When switching the DDRxn bit from output to input no immediate tri-state period is introduced. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 56 Figure 10-3. Switching Between Input and Output in Break-Before-Make-Mode SYSTEM CLK r16 0x02 r17 0x01 INSTRUCTIONS out DDRx, r16 nop out DDRx, r17 PORTx DDRx 0x55 0x02 0x01 Px0 Px1 0x01 tri-state tri-state tri-state intermediate tri-state cycle 10.2.4 intermediate tri-state cycle Reading the Pin Value Independent of the setting of Data Direction bit DDxn, the port pin can be read through the PINxn Register bit. As shown in Figure 10-2 on page 55, the PINxn Register bit and the preceding latch constitute a synchronizer. This is needed to avoid metastability if the physical pin changes value near the edge of the internal clock, but it also introduces a delay. Figure 10-4 shows a timing diagram of the synchronization when reading an externally applied pin value. The maximum and minimum propagation delays are denoted tpd,max and tpd,min respectively. Figure 10-4. Synchronization when Reading an Externally Applied Pin value SYSTEM CLK INSTRUCTIONS XXX XXX in r17, PINx SYNC LATCH PINxn r17 0x00 0xFF 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 indicated by the two arrows tpd,max and tpd,min, a single signal transition on the pin will be delayed between 1/2 and 11/2 system clock period depending upon the time of assertion. When reading back a software assigned pin value, a nop instruction must be inserted as indicated in Figure 10-5 on page 58. 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. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 57 Figure 10-5. Synchronization when Reading a Software Assigned Pin Value SYSTEM CLK r16 INSTRUCTIONS 0xFF out PORTx, r16 nop in r17, PINx SYNC LATCH PINxn r17 0x00 0xFF t pd 10.2.5 Digital Input Enable and Sleep Modes As shown in Figure 10-2 on page 55, the digital input signal can be clamped to ground at the input of the schmitttrigger. The signal denoted SLEEP in the figure, is set by the MCU Sleep Controller in Power-down and Standby modes to avoid high power consumption if some input signals are left floating, or have an analog signal level close to VCC/2. SLEEP is overridden for port pins enabled as external interrupt pins. If the external interrupt request is not enabled, SLEEP is active also for these pins. SLEEP is also overridden by various other alternate functions as described in "Alternate Port Functions" on page 59. If a logic high level ("one") is present on an asynchronous external interrupt pin configured as "Interrupt on Rising Edge, Falling Edge, or Any Logic Change on Pin" while the external interrupt is not enabled, the corresponding External Interrupt Flag will be set when resuming from the above mentioned Sleep mode, as the clamping in these sleep mode produces the requested logic change. 10.2.6 Unconnected Pins If some pins are unused, it is recommended to ensure that these pins have a defined level. Even though most of the digital inputs are disabled in the deep sleep modes as described above, floating inputs should be avoided to reduce current consumption in all other modes where the digital inputs are enabled (Reset, Active mode and Idle mode). The simplest method to ensure a defined level of an unused pin, is to enable the internal pull-up. In this case, the pull-up will be disabled during reset. If low power consumption during reset is important, it is recommended to use an external pull-up or pulldown. Connecting unused pins directly to VCC or GND is not recommended, since this may cause excessive currents if the pin is accidentally configured as an output. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 58 10.2.7 Program Examples The following code example shows how to set port A pins 0 and 1 high, 2 and 3 low, and define the port pins from 4 to 5 as input with a pull-up assigned to port pin 4. The resulting pin values are read back again, but as previously discussed, a nop instruction is included to be able to read back the value recently assigned to some of the pins. Assembly Code Example ... ; Define pull-ups and set outputs high ; Define directions for port pins ldi r16,(1<>8); UBRRnL = (unsigned char)baud; /* Enable receiver and transmitter */ UCSRnB = (1<> 1) & 0x01; return ((resh << 8) | resl); } Note: 1. See "Code Examples" on page 6. The receive function example reads all the I/O Registers into the Register File before any computation is done. This gives an optimal receive buffer utilization since the buffer location read will be free to accept new data as early as possible. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 156 16.8.3 Receive Compete Flag and Interrupt The USART receiver has one flag that indicates the receiver state. The Receive Complete flag (RXCn) indicates if there are unread data present in the receive buffer. This flag is set when unread data exist in the receive buffer, and cleared when the receive buffer is empty (i.e., it does not contain any unread data). If the receiver is disabled (RXENn = 0), the receive buffer will be flushed and, consequently, the RXCn bit will become zero. When the Receive Complete Interrupt Enable (RXCIEn) is set, the USART Receive Complete interrupt will be executed as long as the RXCn flag is set (and provided that global interrupts are enabled). When interrupt-driven data reception is used, the receive complete routine must read the received data from UDRn in order to clear the RXCn flag, otherwise a new interrupt will occur once the interrupt routine terminates. 16.8.4 Receiver Error Flags The USART Receiver has three Error Flags: Frame Error (FEn), Data OverRun (DORn) and Parity Error (UPEn). All can be accessed by reading UCSRnA. Common for the Error Flags is that they are located in the receive buffer together with the frame for which they indicate the error status. Due to the buffering of the Error Flags, the UCSRnA must be read before the receive buffer (UDRn), since reading the UDRn I/O location changes the buffer read location. Another equality for the Error Flags is that they can not be altered by software doing a write to the flag location. However, all flags must be set to zero when the UCSRnA is written for upward compatibility of future USART implementations. None of the Error Flags can generate interrupts. The Frame Error (FEn) Flag indicates the state of the first stop bit of the next readable frame stored in the receive buffer. The FEn Flag is zero when the stop bit was correctly read (as one), and the FEn Flag will be one when the stop bit was incorrect (zero). This flag can be used for detecting out-of-sync conditions, detecting break conditions and protocol handling. The FEn Flag is not affected by the setting of the USBSn bit in UCSRnC since the Receiver ignores all, except for the first, stop bits. For compatibility with future devices, always set this bit to zero when writing to UCSRnA. The Data OverRun (DORn) Flag indicates data loss due to a receiver buffer full condition. A Data OverRun occurs when the receive buffer is full (two characters), it is a new character waiting in the Receive Shift Register, and a new start bit is detected. If the DORn Flag is set there was one or more serial frame lost between the frame last read from UDRn, and the next frame read from UDRn. For compatibility with future devices, always write this bit to zero when writing to UCSRnA. The DORn Flag is cleared when the frame received was successfully moved from the Shift Register to the receive buffer. The Parity Error (UPEn) Flag indicates that the next frame in the receive buffer had a Parity Error when received. If Parity Check is not enabled the UPEn bit will always be read zero. For compatibility with future devices, always set this bit to zero when writing to UCSRnA. For more details see "Parity Bit Calculation" on page 150 and "Parity Checker" on page 157. 16.8.5 Parity Checker The parity checker is active when the high USART Parity Mode bit (UPMn1) is set. The type of parity check to be performed (odd or even) is selected by the UPMn0 bit. When enabled, the parity checker calculates the parity of the data bits in incoming frames and compares the result with the parity bit from the serial frame. The result of the check is stored in the receive buffer together with the received data and stop bits. The Parity Error flag (UPEn) can then be read by software to check if the frame had a parity error. If parity checking is enabled, the UPEn bit is set if the next character that can be read from the receive buffer had a parity error when received. This bit is valid until the receive buffer (UDRn) is read. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 157 16.8.6 Disabling the Receiver Unlike the transmitter, the receiver is disabled immediately and any data from ongoing receptions will be lost. When disabled (RXENn = 0), the receiver will no longer override the normal function of the RxDn port pin and the FIFO buffer is flushed, with any remaining data in the buffer lost. 16.8.7 Flushing the Receive Buffer The receiver buffer FIFO will be flushed when the receiver is disabled, i.e., the buffer will be emptied of its contents. Unread data will be lost. To flush the buffer during normal operation, due to for instance an error condition, read the UDRn until the RXCn flag is cleared. The following code example shows how to flush the receive buffer. Assembly Code Example(1) USART_Flush: sbis UCSRnA, RXCn ret in r16, UDRn rjmp USART_Flush C Code Example(1) void USART_Flush( void ) { unsigned char dummy; while ( UCSRnA & (1< max(16fSCL, 250kHz) V - 1. fCK = CPU clock frequency. Figure 24-3. Two-Wire Serial Bus Timing tOF tHIGH tLOW SCL tSU:STA tHD:STA tR tLOW tHD:DAT tSU:DAT tSU:STO SDA tBUF ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 233 24.7 Analog to Digital Converter Table 24-9. Symbol ADC Characteristics, Single Ended Channels. T = -40C to +85C Parameter Condition Min Typ Resolution Units 10 Bits VREF = 4V, VCC = 4V, ADC clock = 200kHz 2.0 LSB VREF = 4V, VCC = 4V, ADC clock = 1MHz 2.5 LSB VREF = 4V, VCC = 4V, ADC clock = 200kHz Noise Reduction Mode 1.5 LSB VREF = 4V, VCC = 4V, ADC clock = 1MHz Noise Reduction Mode 2.0 LSB Integral Non-Linearity (INL) (Accuracy after Offset and Gain Calibration) VREF = 4V, VCC = 4V, ADC clock = 200kHz 1.0 LSB Differential Non-linearity (DNL) VREF = 4V, VCC = 4V, ADC clock = 200kHz 0.5 LSB Gain Error VREF = 4V, VCC = 4V, ADC clock = 200kHz 2.0 LSB Offset Error (Absolute) VREF = 4V, VCC = 4V, ADC clock = 200kHz 1.5 LSB Conversion Time Free Running Conversion Absolute accuracy (Including INL, DNL, and Quantization, Gain and Offset Errors) Clock Frequency VIN Max Input Voltage 14 280 s 50 1000 kHz GND VREF V Input Bandwidth 38.5 kHz AREF External Voltage Reference 2.0 VINT Internal Voltage Reference 1.0 RREF Reference Input Resistance 32 k RAIN Analog Input Resistance 100 M ADC Conversion Output 0 1.1 VCC V 1.2 V 1023 LSB ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 234 24.8 Analog Comparator Table 24-10. Analog Comparator Characteristics, TA = -40C to +85C Symbol Parameter Condition VAIO Input Offset Voltage VCC = 5V, VIN = VCC / 2 ILAC Input Leakage Current VCC = 5V, VIN = VCC / 2 Analog Propagation Delay (from saturation to slight overdrive) VCC = 2.7V 750 VCC = 4.0V 500 Analog Propagation Delay (large step change) VCC = 2.7V 100 VCC = 4.0V 75 tDPD Digital Propagation Delay VCC = 1.8 - 5.5V 1 24.9 Temperature Sensor tAPD Min Typ Max Units < 10 40 mV 50 nA -50 ns 2 CLK Table 24-11. Accuracy of Temperature Sensor at Factory Calibration Symbol Parameter Condition ATS Accuracy VCC = 4.0, TA = 25C - 85C Note: Min Typ Max Units C 10 1. Firmware calculates temperature based on factory calibration value. 2. Min and max values are not guaranteed. Contact your local Atmel sales office if higher accuracy is required. 24.10 Parallel Programming Figure 24-4. Parallel Programming Timing, Including some General Timing Requirements tXLWL tXHXL CLKI tDVXH tXLDX Data & Contol (DATA, XA0/1, BS1, BS2) tPLBX t BVWL tBVPH PAGEL tWLBX tPHPL tWLWH WR tPLWL WLRL RDY/BSY tWLRH ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 235 Figure 24-5. Parallel Programming Timing, Loading Sequence with Timing Requirements(1) LOAD ADDRESS (LOW BYTE) LOAD DATA LOAD DATA (HIGH BYTE) LOAD DATA (LOW BYTE) t XLXH tXLPH LOAD ADDRESS (LOW BYTE) tPLXH CLKI BS1 PAGEL z DATA ADDR0 (Low Byte) DATA (Low Byte) DATA (High Byte) ADDR1 (Low Byte) XA0 XA1 Note: 1. The timing requirements shown in Figure 24-4 (i.e., tDVXH, tXHXL, and tXLDX) also apply to loading operation. Figure 24-6. Parallel Programming Timing, Reading Sequence (within the Same Page) with Timing Requirements(1) LOAD ADDRESS (LOW BYTE) READ DATA (LOW BYTE) READ DATA (HIGH BYTE) LOAD ADDRESS (LOW BYTE) tXLOL CLKI tBVDV BS1 tOLDV OE DATA tOHDZ ADDR0 (Low Byte) DATA (Low Byte) DATA (High Byte) ADDR1 (Low Byte) XA0 XA1 Note: 1. The timing requirements shown in Figure 24-4 (i.e., tDVXH, tXHXL, and tXLDX) also apply to reading operation. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 236 Table 24-12. Parallel Programming Characteristics, TA = 25C, VCC = 5V Symbol Parameter Min VPP Programming Enable Voltage 11.5 IPP Programming Enable Current tDVXH Data and Control Valid before CLKI High 67 ns tXLXH CLKI Low to CLKI High 200 ns tXHXL CLKI Pulse Width High 150 ns tXLDX Data and Control Hold after CLKI Low 67 ns tXLWL CLKI Low to WR Low 0 ns tXLPH CLKI Low to PAGEL high 0 ns tPLXH PAGEL low to CLKI high 150 ns tBVPH BS1 Valid before PAGEL High 67 ns tPHPL PAGEL Pulse Width High 150 ns tPLBX BS1 Hold after PAGEL Low 67 ns tWLBX BS2/1 Hold after WR Low 67 ns tPLWL PAGEL Low to WR Low 67 ns tBVWL BS1 Valid to WR Low 67 ns tWLWH WR Pulse Width Low 150 ns tWLRL WR Low to RDY/BSY Low tWLRH WR Low to RDY/BSY High(1) (2) Max Units 12.5 V 250 A 0 1 s 3.7 4.5 ms 3.7 9 ms tWLRH_CE WR Low to RDY/BSY High for Chip Erase tXLOL CLKI Low to OE Low 0 tBVDV BS1 Valid to DATA valid 0 tOLDV tOHDZ Notes: Typ ns 250 ns OE Low to DATA Valid 250 ns OE High to DATA Tri-stated 250 ns 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. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 237 24.11 Serial Programming Figure 24-7. Serial Programming Timing MOSI SCK tSLSH tSHOX tOVSH tSHSL MISO Figure 24-8. Serial Programming Waveform SERIAL DATA INPUT (MOSI) MSB LSB SERIAL DATA OUTPUT (MISO) MSB LSB SERIAL CLOCK INPUT (SCK) SAMPLE Table 24-13. Serial Programming Characteristics, TA = -40C to +85C Symbol 1/tCLCL tCLCL 1/tCLCL Parameter Oscillator Frequency @ VCC = 1.8V - 5.5V Oscillator Period @ VCC = 1.8V - 5.5V Oscillator Frequency @ VCC = 4.5V - 5.5V tCLCL Oscillator Period @ VCC = 4.5V - 5.5V tSHSL Min 0 Typ Max Units 1 MHz 1000 0 ns 6 MHz 167 ns SCK Pulse Width High 2 tCLCL ns tSLSH SCK Pulse Width Low 2 tCLCL ns tOVSH MOSI Setup to SCK High tCLCL ns tSHOX MOSI Hold after SCK High 2 tCLCL ns ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 238 25. Typical Characteristics The data contained in this section is largely based on simulations and characterization of similar devices in the same process and design methods. Thus, the data should be treated as indications of how the part will behave. The following charts show typical behavior. These figures are not tested during manufacturing. During characterisation devices are operated at frequencies higher than test limits but they are not guaranteed to function properly at frequencies higher than the ordering code indicates. All current consumption measurements are performed with all I/O pins configured as inputs and with internal pullups enabled. Current consumption is a function of several factors such as operating voltage, operating frequency, loading of I/O pins, switching rate of I/O pins, code executed and ambient temperature. The dominating factors are operating voltage and frequency. A sine wave generator with rail-to-rail output is used as clock source but current consumption in Power-Down mode is independent of clock selection. The difference between current consumption in Power-Down mode with Watchdog Timer enabled and Power-Down mode with Watchdog Timer disabled represents the differential current drawn by the Watchdog Timer. The current drawn from pins with a capacitive load may be estimated (for one pin) as follows: I CP V CC C L f SW where VCC = operating voltage, CL = load capacitance and fSW = average switching frequency of I/O pin. Current Consumption in Active Mode Figure 25-1. Active Supply Current vs. Low Frequency (0.1 - 1.0 MHz) 1 0,9 5.5 V 0,8 5.0 V 0,7 4.5 V 0,6 4.0 V ICC [mA] 25.1 0,5 3.3 V 0,4 2.7 V 0,3 0,2 1.8 V 0,1 0 0 0,1 0,2 0,3 0,4 0,5 0,6 0,7 0,8 0,9 1 Frequency [MHz] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 239 Figure 25-2. Active Supply Current vs. Frequency (1 - 12 MHz) 8 7 5.5 V 6 5.0 V ICC [mA] 5 4.5 V 4 4.0 V 3 3.3 V 2 2.7 V 1 1.8 V 0 0 2 4 6 10 8 12 Frequency [MHz] Figure 25-3. Active Supply Current vs. VCC (Internal Oscillator, 8 MHz) 6 85 25 -40 5 ICC [mA] 4 3 2 1 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC [V] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 240 Figure 25-4. Active Supply Current vs. VCC (Internal Oscillator, 1 MHz) 1,4 85 25 -40 1,2 1 ICC [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 25-5. Active Supply Current vs. VCC (Internal Oscillator, 32kHz) 0,045 0,04 -40 25 85 0,035 ICC [mA] 0,03 0,025 0,02 0,015 0,01 0,005 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC [V] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 241 Current Consumption in Idle Mode Figure 25-6. Idle Supply Current vs. Low Frequency (0.1 - 1.0 MHz) 0,18 0,16 5.5 V 0,14 5.0 V ICC [mA] 0,12 4.5 V 0,1 4.0 V 0,08 3.3 V 0,06 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] Figure 25-7. Idle Supply Current vs. Frequency (1 - 12 MHz) 2 5.5 V 1,8 1,6 5.0 V 1,4 4.5 V 1,2 ICC [mA] 25.2 4.0 V 1 0,8 3.3 V 0,6 2.7 V 0,4 0,2 1.8 V 0 0 2 4 6 8 10 12 Frequency [MHz] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 242 Figure 25-8. Idle Supply Current vs. VCC (Internal Oscillator, 8 MHz) 1,4 85 25 -40 1,2 1 ICC [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 25-9. Idle Supply Current vs. VCC (Internal Oscillator, 1 MHz) 0,5 85 25 -40 0,4 ICC [mA] 0,3 0,2 0,1 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC [V] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 243 Figure 25-10. Idle Supply Current vs. VCC (Internal Oscillator, 32kHz) 0,05 0,04 -40 25 85 ICC 0,03 0,02 0,01 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC Current Consumption in Standby Mode Figure 25-11. Standby Supply Current vs. VCC (Watchdog Timer Enabled) 0,25 8MHz 0,2 0,15 ICC [mA] 25.3 0,1 0,05 32kHz 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC [V] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 244 Current Consumption in Power-down Mode Figure 25-12. Power-down Supply Current vs. VCC (Watchdog Timer Disabled) 1 85 0,8 ICC [uA] 0,6 0,4 0,2 25 -40 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC [V] Figure 25-13. Power-down Supply Current vs. VCC (Watchdog Timer Enabled) 7 6 -40 85 25 5 4 ICC [uA] 25.4 3 2 1 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC [V] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 245 Current Consumption in Reset Figure 25-14. Reset Current vs. Frequency (0.1 - 1MHz, Excluding Pull-Up Current) 1,8 1,6 5.5 V 5.0 V 1,4 4.5 V 1,2 ICC [mA] 4.0 V 1 3.3 V 2.7 V 0,8 0,6 1.8 V 0,4 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] Figure 25-15. Reset Current vs. Frequency (1 - 12MHz, Excluding Pull-Up Current) 10 5.5 V 8 5.0 V 4.5 V 6 4.0 V ICC [mA] 25.5 3.3 V 4 2.7 V 2 1.8 V 0 0 2 4 6 8 10 12 Frequency [MHz] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 246 Figure 25-16. Reset Current vs. VCC (No Clock, excluding Reset Pull-Up Current) 2 -40 85 25 ICC [mA] 1,5 1 0,5 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC [V] Current Consumption of Peripheral Units Figure 25-17. Current Consumption of Peripherals at 1MHz 600 ADC 500 400 ICC [uA] 25.6 300 AC 200 T/C1 T/C0 100 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC [V] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 247 Figure 25-18. Watchdog Timer Current vs. VCC 0,006 -40 25 0,005 85 Icc [mA] 0,004 0,003 0,002 0,001 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC Figure 25-19. Brownout Detector Current vs. VCC 25 85 25 -40 20 ICC [uA] 15 10 5 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC [V] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 248 Figure 25-20. Sampled Brownout Detector Current vs. VCC 8 -40 7 25 6 85 ICC [uA] 5 4 3 2 1 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC [V] Figure 25-21. AREF External Reference Pin Current (VCC = 5V) 160 85 25 -40 140 AREF pin current [uA] 120 100 80 60 40 20 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 AREF [V] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 249 Pull-up Resistors Figure 25-22. I/O pin Pull-up Resistor Current vs. Input Voltage (VCC = 1.8V) 50 25 85 -40 40 IOP [uA] 30 20 10 0 0 0,2 0,4 0,6 0,8 1 1,2 1,4 1,6 1,8 2 VOP [V] Figure 25-23. I/O Pin Pull-up Resistor Current vs. input Voltage (VCC = 2.7V) 80 25 85 -40 60 IOP [uA] 25.7 40 20 0 0 0,5 1 1,5 2 2,5 3 VOP [V] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 250 Figure 25-24. I/O pin Pull-up Resistor Current vs. Input Voltage (VCC = 5V) 140 25 85 -40 120 100 IOP [uA] 80 60 40 20 -0 0 1 2 3 4 5 6 VOP [V] Figure 25-25. Reset Pull-up Resistor Current vs. Reset Pin Voltage (VCC = 1.8V) 40 IRESET [uA] 30 20 10 25 85 -40 0 0 0,2 0,4 0,6 0,8 1 1,2 1,4 1,6 1,8 2 VRESET [V] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 251 Figure 25-26. Reset Pull-up Resistor Current vs. Reset Pin Voltage (VCC = 2.7V) 60 50 IRESET [uA] 40 30 20 10 25 85 -40 0 0 0,5 1 1,5 2 2,5 3 VRESET [V] Figure 25-27. Reset Pull-up Resistor Current vs. Reset Pin Voltage (VCC = 5V) 120 100 IRESET [uA] 80 60 40 20 25 85 -40 0 0 1 2 3 4 5 6 VRESET [V] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 252 Input Thresholds Figure 25-28. VIH: Input Threshold Voltage vs. VCC (I/O Pin, Read as `1') 3 85 25 -40 2,5 Threshold [V] 2 1,5 1 0,5 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC [V] Figure 25-29. VIL: Input Threshold Voltage vs. VCC (I/O Pin, Read as `0') 3 2,5 85 25 -40 2 Threshold [V] 25.8 1,5 1 0,5 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC [V] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 253 Figure 25-30. VIH-VIL: Input Hysteresis vs. VCC (I/O Pin) 0,6 85 25 0,5 0,4 Hysteris [V] -40 0,3 0,2 0,1 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC [V] Figure 25-31. VIH: Input Threshold Voltage vs. VCC (Reset Pin as I/O, Read as `1') 3 -40 25 85 2,5 Threshold [V] 2 1,5 1 0,5 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC [V] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 254 Figure 25-32. VIL: Input Threshold Voltage vs. VCC (Reset Pin as I/O, Read as `0') 3 2,5 85 25 -40 Threshold [V] 2 1,5 1 0,5 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC [V] Figure 25-33. VIH-VIL: Input Hysteresis vs. VCC (Reset Pin as I/O) 0,9 0,8 0,7 85 25 -40 0,6 Hysteresis [V] 0,5 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] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 255 Output Driver Strength Figure 25-34. VOH: Output Voltage vs. Source Current (I/O Pin, VCC = 1.8V) 2 VOH [V] 1,5 1 -40 25 0,5 85 0 0 1 2 3 4 5 IOH [mA] Figure 25-35. VOH: Output Voltage vs. Source Current (I/O Pin, VCC = 3V) 3 -40 25 85 2,5 2 VOH [V] 25.9 1,5 1 0,5 0 0 2 4 6 8 10 IOH [mA] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 256 Figure 25-36. VOH: Output Voltage vs. Source Current (I/O Pin, VCC = 5V) 5 -40 25 85 4 VOH [V] 3 2 1 0 0 5 10 15 20 IOH [mA] Figure 25-37. VOL: Output Voltage vs. Sink Current (I/O Pin, VCC = 1.8V) 1 0,8 85 VOL [V] 0,6 25 0,4 -40 0,2 0 0 1 2 3 4 5 IOL [mA] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 257 Figure 25-38. VOL: Output Voltage vs. Sink Current (I/O Pin, VCC = 3V) 1 0,8 85 VOL [V] 0,6 25 0,4 -40 0,2 0 0 2 4 8 6 10 IOL [mA] Figure 25-39. VOL: Output Voltage vs. Sink Current (I/O Pin, VCC = 5V) 1 85 0,8 25 0,6 VOL [V] -40 0,4 0,2 0 0 5 10 15 20 IOL [mA] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 258 Figure 25-40. VOH: Output Voltage vs. Source Current (Reset Pin as I/O, VCC = 1.8V 2 VOH [V] 1,5 1 0,5 -40 25 85 0 0 0,2 0,4 0,6 0,8 1 IOH [mA] Figure 25-41. VOH: Output Voltage vs. Source Current (Reset Pin as I/O, VCC = 3V 3 2,5 VOH [V] 2 1,5 -40 25 85 1 0,5 0 0 0,2 0,4 0,6 0,8 1 IOH [mA] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 259 Figure 25-42. VOH: Output Voltage vs. Source Current (Reset Pin as I/O, VCC = 5V 5 4 -40 25 85 VOH [V] 3 2 1 0 0 0,2 0,4 0,6 0,8 1 IOH [mA] Figure 25-43. VOL: Output Voltage vs. Sink Current (Reset Pin as I/O, VCC = 1.8V) 1 85 0,8 25 VOL [V] 0,6 -40 0,4 0,2 0 0 0 ,2 0,4 0,6 0,8 1 IOL [mA] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 260 Figure 25-44. VOL: Output Voltage vs. Sink Current (Reset Pin as I/O, VCC = 3V) 1 0,8 85 VOL [V] 0,6 25 0,4 -40 0,2 0 0 0,5 1 1 ,5 2 IOL [mA] Figure 25-45. VOL: Output Voltage vs. Sink Current (Reset Pin as I/O, VCC = 5V) 1 0,8 85 25 VOL [V] 0,6 -40 0,4 0,2 0 0 0,5 1 1,5 2 2,5 3 3,5 4 IOL [mA] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 261 25.10 BOD Figure 25-46. BOD Threshold vs Temperature (BODLEVEL = 4.3V) 4,32 VCC RISING 4,3 4,28 Threshold [V] 4,26 VCC FALLING 4,24 4,22 4,2 4,18 4,16 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 Temperature [C] Figure 25-47. BOD Threshold vs Temperature (BODLEVEL = 2.7V) 2,76 2,74 VCC RISING Threshold [V] 2,72 2,7 2,68 VCC FALLING 2,66 2,64 2,62 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 Temperature [C] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 262 Figure 25-48. BOD Threshold vs Temperature (BODLEVEL = 1.8V) 1,82 VCC RISING 1,81 Threshold [V] 1,8 VCC FALLING 1,79 1,78 1,77 1,76 1,75 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 Temperature [C] Figure 25-49. Sampled BOD Threshold vs Temperature (BODLEVEL = 4.3V) 4,33 VCC RISING 4,32 VCC FALLING 4,31 Threshold [V] 4,3 4,29 4,28 4,27 4,26 4,25 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 Temperature [C] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 263 Figure 25-50. Sampled BOD Threshold vs Temperature (BODLEVEL = 2.7V) 2,76 2,75 VCC RISING VCC FALLING Threshold [V] 2,74 2,73 2,72 2,71 2,7 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 Temperature [C] Figure 25-51. Sampled BOD Threshold vs Temperature (BODLEVEL = 1.8V) 1,8 1,795 Threshold [V] 1,79 VCC RISING 1,785 VCC FALLING 1,78 1,775 1,77 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 Temperature [C] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 264 25.11 Bandgap Voltage Figure 25-52. Bandgap Voltage vs. Supply Voltage 1,08 85 1,075 1,07 25 Bandgap [V] 1,065 1,06 1,055 1,05 -40 1,045 1,04 1,5 2 2,5 3 3,5 4 4,5 5 5,5 Vcc [V] Figure 25-53. Bandgap Voltage vs. Temperature (VCC = 3.3V) 1,07 1,065 Bandgap Voltage [V] 1,06 1,055 1,05 1,045 1,04 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 Temperature [C] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 265 25.12 Reset Figure 25-54. VIH: Input Threshold Voltage vs. VCC (Reset Pin, Read as `1') 3 -40 25 85 2,5 Threshold [V] 2 1,5 1 0,5 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC [V] Figure 25-55. VIL: Input Threshold Voltage vs. VCC (Reset Pin, Read as `0') 3 2,5 85 25 -40 Threshold [V] 2 1,5 1 0,5 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC [V] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 266 Figure 25-56. VIH-VIL: Input Hysteresis vs. VCC (Reset Pin ) 0,7 0,6 Hysteresis [V] 0,5 0,4 0,3 0,2 0,1 -40 25 85 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC [V] Figure 25-57. Minimum Reset Pulse Width vs. VCC 2500 Pulsewidth [ns] 2000 1500 1000 500 85 25 -40 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC [V] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 267 25.13 Analog Comparator Offset Figure 25-58. Analog Comparator Offset vs. VIN (VCC = 5V) 16 -40 14 12 25 Offset [mV] 10 8 85 6 4 2 0 0 0,5 1 1,5 2 2,5 3 3,5 4 4,5 5 Vin [V] Figure 25-59. Analog Comparator Offset vs. VCC (VIN = 1.1V) 8 7 6 Offset [mV] 5 25 -40 85 4 3 2 1 0 1,5 2 2,5 3 3,5 4 4,5 5 5,5 Vcc [V] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 268 Figure 25-60. Analog Comparator Hysteresis vs. VIN (VCC = 5.0V) 45 -40 40 35 25 85 Hysteresis [mV] 30 25 20 15 10 5 0 0 0,5 1 1,5 2 2,5 3 3,5 4 4,5 5 Vin [V] 25.14 Internal Oscillator Speed Figure 25-61. Calibrated Oscillator Frequency (Nominal = 8MHz) vs. VCC 8,4 8,3 85 25 8,2 FRC [MHz] -40 8,1 8 7,9 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC [V] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 269 Figure 25-62. Calibrated Oscillator Frequency (Nominal = 8MHz) vs. Temperature 8,2 8,15 5.0 V FRC [MHz] 8,1 8,05 8 3.0 V 7,95 7,9 -40 -20 0 20 40 60 80 100 Temperature [] Figure 25-63. Calibrated Oscillator Frequency (Nominal = 8MHz) vs. OSCCAL Value 14 12 FRC [MHz] 10 8 6 4 2 0 0 16 32 48 64 80 96 112 128 144 160 176 192 208 224 240 OSCCAL [X1] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 270 Figure 25-64. Calibrated Oscillator Frequency (Nominal = 1MHz) vs. VCC 1,05 1,04 25 85 -40 1,03 FRC [MHz] 1,02 1,01 1 0,99 0,98 0,97 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC [V] Figure 25-65. Calibrated Oscillator Frequency (Nominal = 1MHz) vs. Temperature 1,03 1,02 5.0 V FRC [MHz] 1,01 1 3.0 V 1.8 V 0,99 0,98 0,97 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 Temperature [] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 271 Figure 25-66. ULP Oscillator Frequency (Nominal = 32kHz) vs. VCC 33000 32000 -40 31000 FRC [Hz] 25 30000 85 29000 28000 1,5 2 2,5 3 3,5 4 4,5 5 5,5 VCC [V] Figure 25-67. ULP Oscillator Frequency (Nominal = 32kHz) vs. Temperature 34000 33000 FRC [Hz] 32000 31000 30000 29000 28000 -40 -20 0 20 40 60 80 100 Temperature [] ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 272 26. Register Summary Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 (0xFF) Reserved - - - - - - - - Page(s) (0xFE) Reserved - - - - - - - - (0xFD) Reserved - - - - - - - - (0xFC) Reserved - - - - - - - - (0xFB) Reserved - - - - - - - - (0xFA) Reserved - - - - - - - - (0xF9) Reserved - - - - - - - - ... ... ... ... ... ... ... ... ... ... (0x85) Reserved - - - - - - - - (0x84) Reserved - - - - - - - - (0x83) Reserved - - - - - - - - (0x82) Reserved - - - - - - - - (0x81) - - - - - - - - (0x80) Reserved Reserved - - - - - - - - (0x7F) TWSCRA TWSHE - TWDIE TWASIE TWEN TWSIE TWPME TWSME (0x7E) TWSCRB (0x7D) TWSSRA (0x7C) TWSA TWI Slave Address Register 130 (0x7B) TWSAM TWI Slave Address Mask Register 130 (0x7A) TWSD TWI Slave Data Register (0x79) UCSR1A RXC1 TXC1 UDRE1 FE1 DOR1 UPE1 U2X1 MPCM1 167 (0x78) UCSR1B RXCIE1 TXCIE1 UDRIE1 RXEN1 TXEN1 UCSZ12 RXB81 TXB81 168 (0x77) UCSR1C UMSEL11 UMSEL10 UPM11 UPM01 USBS1 UCSZ11 UCSZ10 UCPOL1 169 (0x76) UCSR1D RXSIE1 RXS1 SFDE1 (0x75) UBRR1H USART1 Baud Rate Register High Byte 172 (0x74) UBRR1L USART1 Baud Rate Register Low Byte 172 (0x73) UDR1 USART1 I/O Data Register (0x72) TCCR1A COM1A1 COM1A0 COM1B1 COM1B0 - - WGM11 WGM10 111 (0x71) TCCR1B ICNC1 ICES1 - WGM13 WGM12 CS12 CS11 CS10 113 (0x70) TCCR1C FOC1A FOC1B - - - - - - 114 (0x6F) TCNT1H Timer/Counter1 - Counter Register High Byte 114 (0x6E) TCNT1L Timer/Counter1 - Counter Register Low Byte 114 (0x6D) OCR1AH Timer/Counter1 - Compare Register A High Byte 114 (0x6C) OCR1AL Timer/Counter1 - Compare Register A Low Byte 114 (0x6B) OCR1BH Timer/Counter1 - Compare Register B High Byte 115 (0x6A) OCR1BL Timer/Counter1 - Compare Register B Low Byte 115 (0x69) ICR1H Timer/Counter1 - Input Capture Register High Byte 115 (0x68) ICR1L Timer/Counter1 - Input Capture Register Low Byte (0x67) GTCCR TSM - - - - - - PSR10 118 (0x66) OSCCAL1 - - - - - - CAL11 CAL10 33 (0x65) OSCTCAL0B Oscillator Temperature Compensation Register B (0x64) OSCTCAL0A Oscillator Temperature Compensation Register A (0x63) OSCCAL0 CAL07 CAL06 CAL05 CAL04 CAL03 CAL02 CAL01 CAL00 32 (0x62) DIDR2 - - - - - ADC11D ADC10D ADC9D 200 TWAA TWDIF TWASIF TWCH TWRA TWC TWBE ... TWCMD[1:0] TWDIR 127 127 TWAS 128 130 171 167 115 33 33 (0x61) DIDR1 - - - - ADC8D ADC7D ADC6D ADC5D 200 (0x60) DIDR0 ADC4D ADC3D ADC2D ADC1D ADC0D AIN1D AIN0D AREFD 184, 200 0x3F (0x5F) SREG I T H S V N Z C 14 0x3E (0x5E) SPH - - - - - SP10 SP9 SP8 13 0x3D (0x5D) SPL SP7 SP6 SP5 SP4 SP3 SP2 SP1 SP0 13 0x3C (0x5C) GIMSK - INT0 PCIE2 PCIE1 - - - 51 0x3B (0x5B) GIFR - INTF0 PCIF2 PCIF1 PCIE0 PCIF0 - - - 52 0x3A (0x5A) TIMSK TOIE1 OCIE1A OCIE1B - ICIE1 OCIE0B TOIE0 OCIE0A 88, 115 0x39 (0x59) TIFR TOV1 OCF1A OCF1B - ICF1 OCF0B TOV0 OCF0A 89, 116 0x38 (0x58) QTCSR 0x37 (0x57) SPMCSR - - RSIG CTPB PGWRT PGERS SPMEN 207 0x36 (0x56) MCUCR - SM1 SM0 SE - - ISC01 ISC00 37, 51 0x35 (0x55) MCUSR - - - - WDRF BORF EXTRF PORF 44 0x34 (0x54) PRR - PRTWI PRTIM0 PRTIM0 PRUSI PRUSART1 PRUSART0 PRADC 38 0x33 (0x53) CLKPR - - - - CLKPS3 CLKPS2 CLKPS1 CLKPS0 31 0x32 (0x52) CLKSR OSCRDY CSTR CKOUT_IO SUT CKSEL3 CKSEL2 CKSEL1 CKSEL0 29 0x31 (0x51) Reserved - - - - - - - - WDIF WDIE WDP3 - WDE WDP2 WDP1 WDP0 QTouch Control and Status Register RFLB 6 0x30 (0x50) WDTCSR 0x2F (0x4F) CCP CPU Change Protection Register 45 13 0x2E (0x4E) DWDR DWDR[7:0] 202 0x2D (0x4D) USIBR USI Buffer Register 144 0x2C (0x4C) USIDR USI Data Register 143 ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 273 Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Page(s) 0x2B (0x4B) USISR USISIF USIOIF USIPF USIDC USICNT3 USICNT2 USICNT1 USICNT0 142 0x2A (0x4A) USICR USISIE USIOIE USIWM1 USIWM0 USICS1 USICS0 USICLK USITC 140 0x29 (0x49) PCMSK2 - - PCINT17 PCINT16 PCINT15 PCINT14 PCINT13 PCINT12 52 0x28 (0x48) PCMSK1 - - - - PCINT11 PCINT10 PCINT9 PCINT8 53 0x27 (0x47) PCMSK0 PCINT7 PCINT6 PCINT5 PCINT4 PCINT3 PCINT2 PCINT1 PCINT0 53 0x26 (0x46) UCSR0A RXC0 TXC0 UDRE0 FE0 DOR0 UPE0 U2X0 MPCM 167 0x25 (0x45) UCSR0B RXCIE0 TXCIE0 UDRIE0 RXEN0 TXEN0 UCSZ02 RXB80 TXB80 168 0x24 (0x44) UCSR0C UMSEL01 UMSEL00 UPM01 UPM00 USBS0 UCSZ01 UCSZ00 UCPOL0 169 0x23 (0x43) UCSR0D RXCIE0 RXS0 SFDE0 - - - - - 171 0x22 (0x42) UBRR0H - - - - 0x21 (0x41) UBRR0L USART0 Baud Rate Register Low Byte 0x20 (0x40) UDR0 USART0 I/O Data Register 0x1F (0x3F) EEARH - - - USART0 Baud Rate Register High Byte - - 0x1E (0x3E) EEARL EEAR[7:0] 0x1D (0x3D) EEDR EEPROM Data Register 0x1C (0x3C) EECR - - EEPM1 EEPM0 172 172 167 - - - 22 EERIE 22 EEMPE EEPE EERE 22 0x1B (0x3B) TCCR0A COM0A1 COM0A0 COM0B1 COM0B0 - - WGM01 WGM00 84 0x1A (0x3A) TCCR0B FOC0A FOC0B - - WGM02 CS02 CS01 CS00 86 0x19 (0x39) TCNT0 Timer/Counter0 88 0x18 (0x38) OCR0A Timer/Counter0 - Compare Register A 88 0x17 (0x37) OCR0B Timer/Counter0 - Compare Register B 88 0x16 (0x36) GPIOR2 General Purpose Register 2 23 0x15 (0x35) GPIOR1 General Purpose Register 1 24 0x14 (0x34) GPIOR0 General Purpose Register 0 0x13 (0x33) PORTCR - - - - - 24 BBMC BBMB BBMA 71 0x12 (0x32) PUEA PUEA7 PUEA6 PUEA5 PUEA4 PUEA3 PUEA2 PUEA1 PUEA0 71 0x11 (0x31) PORTA PORTA7 PORTA6 PORTA5 PORTA4 PORTA3 PORTA2 PORTA1 PORTA0 71 0x10 (0x30) DDRA DDA7 DDA6 DDA5 DDA4 DDA3 DDA2 DDA1 DDA0 71 0x0F (0x2F) PINA PINA7 PINA6 PINA5 PINA4 PINA3 PINA2 PINA1 PINA0 71 0x0E (0x2E) PUEB - - - - PUEB3 PUEB2 PUEB1 PUEB0 72 0x0D (0x2D) PORTB - - - - PORTB3 PORTB2 PORTB1 PORTB0 72 0x0C (0x2C) DDRB - - - - DDB3 DDB2 DDB1 DDB0 72 0x0B (0x2B) PINB - - - - PINB3 PINB2 PINB1 PINB0 72 0x0A (0x2A) PUEC - - PUEC5 PUEC4 PUEC3 PUEC2 PUEC1 PUEC0 72 0x09 (0x29) PORTC - - PORTC5 PORTC4 PORTC3 PORTC2 PORTC1 PORTC0 72 0x08 (0x28) DDRC - - DDC5 DDC4 DDC3 DDC2 DDC1 DDC0 72 0x07 (0x27) PINC - - PINC5 PINC4 PINC3 PINC2 PINC1 PINC0 72 0x06 (0x26) ACSRA ACD ACBG ACO ACI ACIE ACIC ACIS1 ACIS0 182 0x05 (0x25) ACSRB HSEL HLEV ACLP - ACCE ACME ACIRS1 ACIRS0 183 0x04 (0x24) ADMUX REFS1 REFS0 REFEN ADC0EN MUX3 MUX2 MUX1 MUX0 196 0x03 (0x23) ADCSRA ADEN ADSC ADATE ADIF ADIE ADPS2 ADPS1 ADPS0 197 0x02 (0x22) ADCSRB VDEN VDPD - - ADLAR ADTS2 ADTS1 ADTS0 199 0x01 (0x21) ADCH ADC Data Register High Byte 198 0x00 (0x20) ADCL ADC Data Register Low Byte 198 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. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 274 27. Instruction Set Summary Mnemonics Operands Description Operation Flags #Clocks ARITHMETIC AND LOGIC INSTRUCTIONS ADD Rd, Rr Add two Registers Rd Rd + Rr Z,C,N,V,H ADC Rd, Rr Add with Carry two Registers Rd Rd + Rr + C Z,C,N,V,H 1 ADIW Rdl,K Add Immediate to Word Rdh:Rdl Rdh:Rdl + K Z,C,N,V,S 2 SUB Rd, Rr Subtract two Registers Rd Rd - Rr Z,C,N,V,H 1 SUBI Rd, K Subtract Constant from Register Rd Rd - K Z,C,N,V,H 1 SBC Rd, Rr Subtract with Carry two Registers Rd Rd - Rr - C Z,C,N,V,H 1 1 SBCI Rd, K Subtract with Carry Constant from Reg. Rd Rd - K - C Z,C,N,V,H 1 SBIW Rdl,K Subtract Immediate from Word Rdh:Rdl Rdh:Rdl - K Z,C,N,V,S 2 1 AND Rd, Rr Logical AND Registers Rd Rd Rr Z,N,V ANDI Rd, K Logical AND Register and Constant Rd Rd K Z,N,V 1 OR Rd, Rr Logical OR Registers Rd Rd v Rr Z,N,V 1 ORI Rd, K Logical OR Register and Constant Rd Rd v K Z,N,V 1 EOR Rd, Rr Exclusive OR Registers Rd Rd Rr Z,N,V 1 COM Rd One's Complement Rd 0xFF Rd Z,C,N,V 1 NEG Rd Two's Complement Rd 0x00 Rd Z,C,N,V,H 1 SBR Rd,K Set Bit(s) in Register Rd Rd v K Z,N,V 1 CBR Rd,K Clear Bit(s) in Register Rd Rd (0xFF - K) Z,N,V 1 INC Rd Increment Rd Rd + 1 Z,N,V 1 DEC Rd Decrement Rd Rd 1 Z,N,V 1 TST Rd Test for Zero or Minus Rd Rd Rd Z,N,V 1 CLR Rd Clear Register Rd Rd Rd Z,N,V 1 SER Rd Set Register Rd 0xFF None 1 3 BRANCH INSTRUCTIONS JMP k Direct Jump PC k None RJMP k Relative Jump PC PC + k + 1 None 2 Indirect Jump to (Z) PC Z None 2 4 IJMP CALL k Direct Subroutine PC k None RCALL k Relative Subroutine Call PC PC + k + 1 None 3 ICALL Indirect Call to (Z) PC Z None 3 RET Subroutine Return PC STACK None 4 RETI Interrupt Return PC STACK I if (Rd = Rr) PC PC + 2 or 3 None 4 CPSE Rd,Rr Compare, Skip if Equal 1/2/3 CP Rd,Rr Compare Rd Rr Z, N,V,C,H 1 CPC Rd,Rr Compare with Carry Rd Rr C Z, N,V,C,H 1 CPI Rd,K Compare Register with Immediate Rd K Z, N,V,C,H SBRC Rr, b Skip if Bit in Register Cleared if (Rr(b)=0) PC PC + 2 or 3 None 1 1/2/3 SBRS Rr, b Skip if Bit in Register is Set if (Rr(b)=1) PC PC + 2 or 3 None 1/2/3 SBIC P, b Skip if Bit in I/O Register Cleared if (P(b)=0) PC PC + 2 or 3 None 1/2/3 SBIS P, b Skip if Bit in I/O Register is Set if (P(b)=1) PC PC + 2 or 3 None 1/2/3 BRBS s, k Branch if Status Flag Set if (SREG(s) = 1) then PCPC+k + 1 None 1/2 BRBC s, k Branch if Status Flag Cleared if (SREG(s) = 0) then PCPC+k + 1 None 1/2 BREQ k Branch if Equal if (Z = 1) then PC PC + k + 1 None 1/2 BRNE k Branch if Not Equal if (Z = 0) then PC PC + k + 1 None 1/2 BRCS k Branch if Carry Set if (C = 1) then PC PC + k + 1 None 1/2 BRCC k Branch if Carry Cleared if (C = 0) then PC PC + k + 1 None 1/2 BRSH k Branch if Same or Higher if (C = 0) then PC PC + k + 1 None 1/2 BRLO k Branch if Lower if (C = 1) then PC PC + k + 1 None 1/2 BRMI k Branch if Minus if (N = 1) then PC PC + k + 1 None 1/2 BRPL k Branch if Plus if (N = 0) then PC PC + k + 1 None 1/2 BRGE k Branch if Greater or Equal, Signed if (N V= 0) then PC PC + k + 1 None 1/2 BRLT k Branch if Less Than Zero, Signed if (N V= 1) then PC PC + k + 1 None 1/2 BRHS k Branch if Half Carry Flag Set if (H = 1) then PC PC + k + 1 None 1/2 BRHC k Branch if Half Carry Flag Cleared if (H = 0) then PC PC + k + 1 None 1/2 BRTS k Branch if T Flag Set if (T = 1) then PC PC + k + 1 None 1/2 BRTC k Branch if T Flag Cleared if (T = 0) then PC PC + k + 1 None 1/2 BRVS k Branch if Overflow Flag is Set if (V = 1) then PC PC + k + 1 None 1/2 BRVC k Branch if Overflow Flag is Cleared if (V = 0) then PC PC + k + 1 None 1/2 BRIE k Branch if Interrupt Enabled if ( I = 1) then PC PC + k + 1 None 1/2 BRID k Branch if Interrupt Disabled if ( I = 0) then PC PC + k + 1 None 1/2 BIT AND BIT-TEST INSTRUCTIONS SBI P,b Set Bit in I/O Register I/O(P,b) 1 None 2 CBI P,b Clear Bit in I/O Register I/O(P,b) 0 None 2 LSL Rd Logical Shift Left Rd(n+1) Rd(n), Rd(0) 0 Z,C,N,V 1 LSR Rd Logical Shift Right Rd(n) Rd(n+1), Rd(7) 0 Z,C,N,V 1 ROL Rd Rotate Left Through Carry Rd(0)C,Rd(n+1) Rd(n),CRd(7) Z,C,N,V 1 ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 275 Mnemonics Operands Description Operation Flags #Clocks ROR Rd Rotate Right Through Carry Rd(7)C,Rd(n) Rd(n+1),CRd(0) Z,C,N,V 1 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 1 SEC Set Carry C1 C CLC Clear Carry C0 C 1 SEN Set Negative Flag N1 N 1 CLN Clear Negative Flag N0 N 1 SEZ Set Zero Flag Z1 Z 1 CLZ Clear Zero Flag Z0 Z 1 SEI Global Interrupt Enable I1 I 1 CLI Global Interrupt Disable I 0 I 1 1 SES Set Signed Test Flag S1 S CLS Clear Signed Test Flag S0 S 1 SEV Set Twos Complement Overflow. V1 V 1 CLV Clear Twos Complement Overflow V0 V 1 SET Set T in SREG T1 T 1 CLT Clear T in SREG T0 T 1 SEH CLH Set Half Carry Flag in SREG Clear Half Carry Flag in SREG H1 H0 H H 1 None 1 None 1 1 DATA TRANSFER INSTRUCTIONS MOV Rd, Rr Move Between Registers MOVW Rd, Rr Copy Register Word Rd Rr Rd+1:Rd Rr+1:Rr 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 2 LD Rd, Y Load Indirect Rd (Y) None 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 2 LDS Rd, k Load Direct from SRAM Rd (k) None 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 Load Program Memory R0 (Z) None 3 LPM 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 Store Program Memory (z) R1:R0 None SPM IN Rd, P In Port Rd P None 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 1 MCU CONTROL INSTRUCTIONS NOP No Operation None 1 SLEEP Sleep (see specific descr. for Sleep function) None 1 WDR BREAK Watchdog Reset Break (see specific descr. for WDR/Timer) For On-chip Debug Only None None 1 N/A ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 276 28. Ordering Information 28.1 ATtiny1634 Speed (MHz) (1) Supply Voltage (V) Temperature Range Package (2) Accuracy (3) Ordering Code (4) 10% ATtiny1634-MU 2% ATtiny1634R-MU 10% ATtiny1634-MUR 2% ATtiny1634R-MUR 10% ATtiny1634-SU 2% ATtiny1634R-SU 10% ATtiny1634-SUR 2% ATtiny1634R-SUR 20M1 12 1.8 - 5.5 Industrial (-40C to +85C) (5) 20S2 Notes: 1. For speed vs. supply voltage, see section 24.3 "Speed" on page 229. 2. All packages are Pb-free, halide-free and fully green, and they comply with the European directive for Restriction of Hazardous Substances (RoHS). 3. Denotes accuracy of the internal oscillator. See Table 24-2 on page 230. 4. Code indicators: - U: matte tin - R: tape & reel 5. Can also be supplied in wafer form. Contact your local Atmel sales office for ordering information and minimum quantities. Package Type 20M1 20-pad, 4 x 4 x 0.8 mm Body, Quad Flat No-Lead / Micro Lead Frame Package (QFN/MLF) 20S2 20-lead, 0.300" Wide Body, Plastic Gull Wing Small Outline Package (SOIC) ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 277 29. Packaging Information 29.1 20M1 D 1 Pin 1 ID 2 SIDE VIEW E 3 TOP VIEW A2 D2 A1 A 0.08 1 2 Pin #1 Notch (0.20 R) 3 COMMON DIMENSIONS (Unit of Measure = mm) E2 b L e BOTTOM VIEW SYMBOL MIN NOM MAX A 0.70 0.75 0.80 A1 - 0.01 0.05 A2 b D D2 E2 L 0.23 0.30 4.00 BSC 2.45 2.60 2.75 4.00 BSC 2.45 e Reference JEDEC Standard MO-220, Fig. 1 (SAW Singulation) WGGD-5. NOTE 0.20 REF 0.18 E Note: C 2.60 2.75 0.50 BSC 0.35 0.40 0.55 10/27/04 R 2325 Orchard Parkway San Jose, CA 95131 TITLE 20M1, 20-pad, 4 x 4 x 0.8 mm Body, Lead Pitch 0.50 mm, 2.6 mm Exposed Pad, Micro Lead Frame Package (MLF) DRAWING NO. 20M1 ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 REV. B 278 29.2 20S2 ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 279 30. Errata The revision letters in this section refer to the revision of the corresponding ATtiny1634 device. 30.1 ATtiny1634 30.1.1 Rev. B * Port Pin Should Not Be Used As Input When ULP Oscillator Is Disabled 1. Port Pin Should Not Be Used As Input When ULP Oscillator Is Disabled Port pin PB3 is not guaranteed to perform as a reliable input when the Ultra Low Power (ULP) oscillator is not running. In addition, the pin is pulled down internally when ULP oscillator is disabled. Problem Fix / Workaround The ULP oscillator is automatically activated when required. To use PB3 as an input, activate the watchdog timer. The watchdog timer automatically enables the ULP oscillator. 30.1.2 Rev. A * Flash / EEPROM Can Not Be Written When Supply Voltage Is Below 2.4V * Port Pin Should Not Be Used As Input When ULP Oscillator Is Disabled 1. Flash / EEPROM Can Not Be Written When Supply Voltage Is Below 2.4V When supply voltage is below 2.4V write operations to Flash and EEPROM may fail. Problem Fix / Workaround Do not write to Flash or EEPROM when supply voltage is below 2.4V. 2. Port Pin Should Not Be Used As Input When ULP Oscillator Is Disabled Port pin PB3 is not guaranteed to perform as a reliable input when the Ultra Low Power (ULP) oscillator is not running. In addition, the pin is pulled down internally when ULP oscillator is disabled. Problem Fix / Workaround The ULP oscillator is automatically activated when required. To use PB3 as an input, activate the watchdog timer. The watchdog timer automatically enables the ULP oscillator. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 280 31. Datasheet Revision History 31.1 Rev. 8303G - 11/2013 1. Removed references to Wafer Level Chip Scale Package option. 31.2 Rev. 8303F - 08/2013 1. Updated Bit 2 from the UCSR1C register from "USBSZ11" to "UCSZ11" in "Register Summary" on page 273. 31.3 Rev. 8303E - 01/2013 1. Updated: - Applied the Atmel new brand template that includes new log and new addresses. 31.4 Rev. 8303D - 06/12 1. Updated: - "Ordering Information" on page 277 2. Added: - Wafer Level Chip Scale Package "Errata" on page 280 31.5 Rev. 8303C - 03/12 1. Updated: - "Register Description" on page 167 - "Self-Programming" on page 203 31.6 Rev. 8303B - 03/12 1. Removed Preliminary status. 2. Added: - "Typical Characteristics" on page 239 - "Temperature Sensor" on page 235 - "Rev. B" on page 280 3. Updated: - "Pin Descriptions" on page 3 - "Calibrated Internal 8MHz Oscillator" on page 27 - "OSCTCAL0A - Oscillator Temperature Calibration Register A" on page 33 - "OSCTCAL0B - Oscillator Temperature Calibration Register B" on page 33 - "TWSCRA - TWI Slave Control Register A" on page 127 - "USART (USART0 & USART1)" on page 145 - "Temperature vs. Sensor Output Voltage (Typical)" on page 195 - "DC Characteristics" on page 228 - "Calibration Accuracy of Internal 32kHz Oscillator" on page 231 - "External Clock Drive Characteristics" on page 231 - "Reset, Brown-out, and Internal Voltage Characteristics" on page 231 - "Analog Comparator Characteristics, TA = -40C to +85C" on page 235 ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 281 - "Parallel Programming Characteristics, TA = 25C, VCC = 5V" on page 237 - "Serial Programming Characteristics, TA = -40C to +85C" on page 238 - "Ordering Information" on page 277 31.7 Rev. 8303A - 11/11 Initial revision. ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 282 Table of Contents Features ..................................................................................................... 1 1 Pin Configurations ................................................................................... 2 1.1 Pin Descriptions .................................................................................................3 2 Overview ................................................................................................... 4 3 General Information ................................................................................. 6 4 5 6 7 3.1 Resources .........................................................................................................6 3.2 Code Examples .................................................................................................6 3.3 Capacitive Touch Sensing .................................................................................6 3.4 Data Retention ...................................................................................................6 CPU Core ................................................................................................... 6 4.1 Architectural Overview .......................................................................................7 4.2 ALU - Arithmetic Logic Unit ...............................................................................8 4.3 Status Register ..................................................................................................8 4.4 General Purpose Register File ..........................................................................8 4.5 Stack Pointer ...................................................................................................10 4.6 Instruction Execution Timing ...........................................................................10 4.7 Reset and Interrupt Handling ...........................................................................11 4.8 Register Description ........................................................................................13 Memories ................................................................................................. 14 5.1 Program Memory (Flash) .................................................................................15 5.2 Data Memory (SRAM) and Register Files .......................................................16 5.3 Data Memory (EEPROM) ................................................................................18 5.4 Register Description ........................................................................................22 Clock System .......................................................................................... 24 6.1 Clock Subsystems ...........................................................................................25 6.2 Clock Sources .................................................................................................26 6.3 System Clock Prescaler ..................................................................................28 6.4 Clock Output Buffer .........................................................................................29 6.5 Register Description ........................................................................................29 Power Management and Sleep Modes ................................................. 34 7.1 Sleep Modes ....................................................................................................34 7.2 Power Reduction Register ...............................................................................36 7.3 Minimizing Power Consumption ......................................................................36 ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 i 7.4 8 9 Register Description ........................................................................................37 System Control and Reset ..................................................................... 39 8.1 Resetting the AVR ...........................................................................................39 8.2 Reset Sources .................................................................................................39 8.3 Internal Voltage Reference ..............................................................................42 8.4 Watchdog Timer ..............................................................................................43 8.5 Register Description ........................................................................................44 Interrupts ................................................................................................. 47 9.1 Interrupt Vectors ..............................................................................................47 9.2 External Interrupts ...........................................................................................48 9.3 Register Description ........................................................................................51 10 I/O Ports .................................................................................................. 54 10.1 Overview ..........................................................................................................54 10.2 Ports as General Digital I/O .............................................................................54 10.3 Alternate Port Functions ..................................................................................59 10.4 Register Description ........................................................................................71 11 8-bit Timer/Counter0 with PWM ............................................................ 73 11.1 Features ..........................................................................................................73 11.2 Overview ..........................................................................................................73 11.3 Clock Sources .................................................................................................74 11.4 Counter Unit ....................................................................................................74 11.5 Output Compare Unit .......................................................................................75 11.6 Compare Match Output Unit ............................................................................77 11.7 Modes of Operation .........................................................................................78 11.8 Timer/Counter Timing Diagrams ......................................................................82 11.9 Register Description ........................................................................................84 12 16-bit Timer/Counter1 ............................................................................ 90 12.1 Features ..........................................................................................................90 12.2 Overview ..........................................................................................................90 12.3 Timer/Counter Clock Sources .........................................................................92 12.4 Counter Unit ....................................................................................................92 12.5 Input Capture Unit ...........................................................................................93 12.6 Output Compare Units .....................................................................................95 12.7 Compare Match Output Unit ............................................................................97 12.8 Modes of Operation .........................................................................................98 ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 ii 12.9 Timer/Counter Timing Diagrams ....................................................................106 12.10 Accessing 16-bit Registers ............................................................................107 12.11 Register Description ......................................................................................111 13 Timer/Counter Prescaler ...................................................................... 117 13.1 Prescaler Reset .............................................................................................117 13.2 External Clock Source ...................................................................................118 13.3 Register Description ......................................................................................118 14 I2C Compatible, Two-Wire Slave Interface ......................................... 119 14.1 Features ........................................................................................................119 14.2 Overview ........................................................................................................119 14.3 General TWI Bus Concepts ...........................................................................119 14.4 TWI Slave Operation .....................................................................................125 14.5 Register Description ......................................................................................127 15 USI - Universal Serial Interface .......................................................... 131 15.1 Features ........................................................................................................131 15.2 Overview ........................................................................................................131 15.3 Three-wire Mode ...........................................................................................132 15.4 Two-wire Mode ..............................................................................................134 15.5 Alternative Use ..............................................................................................136 15.6 Program Examples ........................................................................................137 15.7 Register Descriptions ....................................................................................140 16 USART (USART0 & USART1) .............................................................. 145 16.1 Features ........................................................................................................145 16.2 USART0 and USART1 ..................................................................................145 16.3 Overview ........................................................................................................145 16.4 Clock Generation ...........................................................................................147 16.5 Frame Formats ..............................................................................................149 16.6 USART Initialization .......................................................................................151 16.7 Data Transmission - The USART Transmitter ..............................................152 16.8 Data Reception - The USART Receiver .......................................................154 16.9 Asynchronous Data Reception ......................................................................158 16.10 Multi-processor Communication Mode ..........................................................162 16.11 Examples of Baud Rate Setting .....................................................................163 16.12 Register Description ......................................................................................167 17 USART in SPI Mode .............................................................................. 173 ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 iii 17.1 Features ........................................................................................................173 17.2 Overview ........................................................................................................173 17.3 Clock Generation ...........................................................................................173 17.4 SPI Data Modes and Timing ..........................................................................173 17.5 Frame Formats ..............................................................................................174 17.6 Data Transfer .................................................................................................176 17.7 Compatibility with AVR SPI ...........................................................................178 17.8 Register Description ......................................................................................178 18 Analog Comparator .............................................................................. 181 18.1 Analog Comparator Multiplexed Input ...........................................................181 18.2 Register Description ......................................................................................182 19 Analog to Digital Converter ................................................................. 185 19.1 Features ........................................................................................................185 19.2 Overview ........................................................................................................185 19.3 Operation .......................................................................................................186 19.4 Starting a Conversion ....................................................................................187 19.5 Prescaling and Conversion Timing ................................................................188 19.6 Changing Channel or Reference Selection ...................................................191 19.7 ADC Noise Canceler .....................................................................................192 19.8 Analog Input Circuitry ....................................................................................192 19.9 Noise Canceling Techniques .........................................................................193 19.10 ADC Accuracy Definitions .............................................................................193 19.11 ADC Conversion Result .................................................................................195 19.12 Temperature Measurement ...........................................................................195 19.13 Register Description ......................................................................................196 20 debugWIRE On-chip Debug System ................................................... 201 20.1 Features ........................................................................................................201 20.2 Overview ........................................................................................................201 20.3 Physical Interface ..........................................................................................201 20.4 Software Break Points ...................................................................................202 20.5 Limitations of debugWIRE .............................................................................202 20.6 Register Description ......................................................................................202 21 Self-Programming ................................................................................ 203 21.1 Features ........................................................................................................203 21.2 Overview ........................................................................................................203 ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 iv 21.3 Lock Bits ........................................................................................................203 21.4 Self-Programming the Flash ..........................................................................203 21.5 Preventing Flash Corruption ..........................................................................206 21.6 Programming Time for Flash when Using SPM .............................................206 21.7 Register Description ......................................................................................207 22 Lock Bits, Fuse Bits and Device Signature ....................................... 208 22.1 Lock Bits ........................................................................................................208 22.2 Fuse Bits ........................................................................................................209 22.3 Device Signature Imprint Table .....................................................................210 22.4 Reading Lock, Fuse and Signature Data from Software ...............................211 23 External Programming ......................................................................... 214 23.1 Memory Parametrics .....................................................................................214 23.2 Parallel Programming ....................................................................................214 23.3 Serial Programming .......................................................................................223 23.4 Programming Time for Flash and EEPROM ..................................................227 24 Electrical Characteristics .................................................................... 228 24.1 Absolute Maximum Ratings* .........................................................................228 24.2 DC Characteristics .........................................................................................228 24.3 Speed ............................................................................................................229 24.4 Clock ..............................................................................................................230 24.5 System and Reset .........................................................................................231 24.6 Two-Wire Serial Interface ..............................................................................233 24.7 Analog to Digital Converter ............................................................................234 24.8 Analog Comparator .......................................................................................235 24.9 Temperature Sensor ......................................................................................235 24.10 Parallel Programming ....................................................................................235 24.11 Serial Programming .......................................................................................238 25 Typical Characteristics ........................................................................ 239 25.1 Current Consumption in Active Mode ............................................................239 25.2 Current Consumption in Idle Mode ................................................................242 25.3 Current Consumption in Standby Mode ........................................................244 25.4 Current Consumption in Power-down Mode ..................................................245 25.5 Current Consumption in Reset ......................................................................246 25.6 Current Consumption of Peripheral Units ......................................................247 25.7 Pull-up Resistors ...........................................................................................250 ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 v 25.8 Input Thresholds ............................................................................................253 25.9 Output Driver Strength ...................................................................................256 25.10 BOD ...............................................................................................................262 25.11 Bandgap Voltage ...........................................................................................265 25.12 Reset .............................................................................................................266 25.13 Analog Comparator Offset .............................................................................268 25.14 Internal Oscillator Speed ...............................................................................269 26 Register Summary ................................................................................ 273 27 Instruction Set Summary ..................................................................... 275 28 Ordering Information ........................................................................... 277 28.1 ATtiny1634 ....................................................................................................277 29 Packaging Information ......................................................................... 278 29.1 20M1 ..............................................................................................................278 29.2 20S2 ..............................................................................................................279 30 Errata ..................................................................................................... 280 30.1 ATtiny1634 ....................................................................................................280 31 Datasheet Revision History ................................................................. 281 31.1 Rev. 8303G - 11/2013 ..................................................................................281 31.2 Rev. 8303F - 08/2013 ...................................................................................281 31.3 Rev. 8303E - 01/2013 ...................................................................................281 31.4 Rev. 8303D - 06/12 .......................................................................................281 31.5 Rev. 8303C - 03/12 .......................................................................................281 31.6 Rev. 8303B - 03/12 .......................................................................................281 31.7 Rev. 8303A - 11/11 .......................................................................................282 Table of Contents ....................................................................................... i ATtiny1634 [DATASHEET] 8303G-AVR-11/2013 vi Atmel Corporation 1600 Technology Drive Atmel Asia Limited Unit 01-5 & 16, 19F Atmel Munich GmbH Business Campus Atmel Japan G.K. 16F Shin-Osaki Kangyo Bldg San Jose, CA 95110 BEA Tower, Millennium City 5 Parkring 4 1-6-4 Osaki, Shinagawa-ku USA 418 Kwun Tong Roa D-85748 Garching b. Munich Tokyo 141-0032 Tel: (+1) (408) 441-0311 Kwun Tong, Kowloon GERMANY JAPAN Fax: (+1) (408) 487-2600 HONG KONG Tel: (+49) 89-31970-0 Tel: (+81) (3) 6417-0300 www.atmel.com Tel: (+852) 2245-6100 Fax: (+49) 89-3194621 Fax: (+81) (3) 6417-0370 Fax: (+852) 2722-1369 (c) 2013 Atmel Corporation. All rights reserved. / Rev.: 8303G-AVR-11/2013 Atmel(R), Atmel logo and combinations thereof, Enabling Unlimited Possibilities(R), AVR(R), tinyAVR(R), QTouch(R) and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others. 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 THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, 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 INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS AND 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 products 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 products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.