
- •Features
- •Pin Configuration
- •Disclaimer
- •Description
- •Pin Descriptions
- •AVCC
- •Port A (PA7..PA0)
- •Port B (PB7..PB0)
- •XTAL1
- •XTAL2
- •SRAM Data Memory
- •I/O Direct
- •Data Direct
- •Data Indirect with Displacement
- •Data Indirect
- •EEPROM Data Memory
- •I/O Memory
- •Status Register – SREG
- •Stack Pointer – SP
- •Reset Sources
- •Power-on Reset
- •External Reset
- •Brown-out Detection
- •Watchdog Reset
- •Clock Systems and their Distribution
- •CPU Clock – clkCPU
- •I/O Clock – clkI/O
- •Flash Clock – clkFLASH
- •ADC Clock – clkADC
- •Internal PLL for Fast Peripheral Clock Generation – clkPCK
- •Clock Sources
- •Crystal Oscillator
- •External RC Oscillator
- •External Clock
- •Interrupt Handling
- •Interrupt Response Time
- •External Interrupt
- •Pin Change Interrupt
- •Idle Mode
- •ADC Noise Reduction Mode
- •Power-down Mode
- •Standby Mode
- •Analog to Digital Converter
- •Analog Comparator
- •Brown-out Detector
- •Internal Voltage Reference
- •Watchdog Timer
- •Port Pins
- •Timer/Counters
- •Timer/Counter0 Prescaler
- •Timer/Counter1 Prescaler
- •8-bit Timer/Counter0
- •Timer/Counter0 – TCNT0
- •8-bit Timer/Counter1
- •Timer/Counter1 – TCNT1
- •Timer/Counter1 in PWM Mode
- •Watchdog Timer
- •Overview
- •Register Descriptions
- •USI Data Register – USIDR
- •USI Status Register – USISR
- •USI Control Register – USICR
- •Functional Descriptions
- •Three-wire Mode
- •SPI Slave Operation Example
- •Two-wire Mode
- •Start Condition Detector
- •Alternative USI Usage
- •4-bit Counter
- •12-bit Timer/Counter
- •Software Interrupt
- •Analog Comparator
- •Analog to Digital Converter
- •Features
- •Operation
- •ADC Conversion Result
- •ADLAR = 0
- •ADLAR = 1
- •I/O Ports
- •Introduction
- •Configuring the Pin
- •Reading the Pin Value
- •Alternate Port Functions
- •Alternate Functions of Port A
- •Alternate Functions Of Port B
- •Register Description for I/O Ports
- •Port A Data Register – PORTA
- •Port B Data Register – PORTB
- •Fuse Bits
- •Latching of Fuses
- •Signature Bytes
- •Calibration Byte
- •Signal Names
- •Parallel Programming
- •Enter Programming Mode
- •Chip Erase
- •Programming the Flash
- •Programming the EEPROM
- •Reading the Flash
- •Reading the EEPROM
- •Programming the Lock Bits
- •Reading the Signature Bytes
- •Reading the Calibration Byte
- •Serial Downloading
- •Data Polling Flash
- •Data Polling EEPROM
- •Electrical Characteristics
- •Absolute Maximum Ratings*
- •External Clock Drive Waveforms
- •External Clock Drive
- •ADC Characteristics – Preliminary Data
- •ATtiny26/L Register Summary
- •Ordering Information(1)
- •Packaging Information
- •Data Sheet Change Log for ATtiny26
- •Changes from Rev. 1477A-03/02 to Rev. 1477B-04/02
- •Table of Contents

ADC Noise Canceler
Function
ADC Conversion Result
The ADC features a noise canceler that enables conversion during ADC Noise Reduction mode (see “Power Management and Sleep Modes” on page 41) to reduce noise induced from the CPU core and other I/O peripherals. If other I/O peripherals must be active during conversion, this mode works equivalently for Idle mode. To make use of this feature, the following procedure should be used:
1.Make sure that the ADC is enabled and is not busy converting. Single Conversion mode must be selected and the ADC conversion complete interrupt must be enabled.
ADEN = 1 ADSC = 0 ADFR = 0 ADIE = 1
2.Enter ADC Noise Reduction mode (or Idle mode). The ADC will start a conversion once the CPU has been halted.
3.If no other interrupts occur before the ADC conversion completes, the ADC interrupt will wake up the CPU and execute the ADC Conversion Complete interrupt routine.
After the conversion is complete (ADIF is high), the conversion result can be found in the ADC Result Registers (ADCL, ADCH).
For single ended conversion, the result is
VIN 1024
ADC = --------------------------
VREF
where VIN is the voltage on the selected input pin and VREF the selected voltage reference (see Table 36 on page 84 and Table 37 on page 85). 0x000 represents analog
ground, and 0x3FF represents the selected reference voltage minus one LSB.
If differential channels are used, the result is
(VPOS – VN E G ) GAIN 1024
ADC = ---------------------------------------------------------------------------
VREF
where VPOS is the voltage on the positive input pin, VNEG the voltage on the negative input pin, GAIN the selected gain factor, and VREF the selected voltage reference. Keep in mind that VPOS must be higher than VNEG, otherwise, the ADC value will saturate at 0x000. Figure 51 shows the decoding of the differential input range.
Table 35 shows the resulting output codes if the differential input channel pair (ADCn - ADCm) is selected with a gain of GAIN and a reference voltage of VREF.
82 ATtiny26(L)
1477B–AVR–04/02

ATtiny26(L)
Figure 51. Differential Measurement Range
Output Code |
|
|
|
|
0x3FF |
|
|
|
|
0x000 |
|
|
|
|
0 |
V |
REF |
/GAIN |
Differential Input |
|
|
|
Voltage (Volts) |
|
|
|
|
|
Table 35. Correlation Between Input Voltage and Output Codes
VADCn |
Read code |
Corresponding decimal value |
VADCm + VREF /GAIN |
0x3FF |
1023 |
|
|
|
VADCm + 0.999 VREF /GAIN |
0x3FF |
1023 |
|
|
|
VADCm + 0.998 VREF /GAIN |
0x3FE |
1022 |
... |
... |
... |
|
|
|
VADCm + 0.001 VREF /GAIN |
0x001 |
1 |
|
|
|
VADCm |
0x000 |
0 |
Example:
ADMUX = 0xEB (ADC0 - ADC1, 20x gain, 2.56V reference, left adjusted result)
Voltage on ADC0 is 400 mV, voltage on ADC1 is 300 mV.
ADCR = 1024 * 20 * (400 - 300) / 2560 = 800 = 0x320
ADCL will thus read 0x00, and ADCH will read 0xC8. Writing zero to ADLAR right adjusts the result: ADCL = 0x20, ADCH = 0x03.
83
1477B–AVR–04/02

ADC Multiplexer Selection
Register – ADMUX
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bit |
7 |
6 |
|
5 |
|
4 |
3 |
2 |
1 |
0 |
|
||
|
|
|
|
|
|
|
|
|
|
|
|
||
$07 ($27) |
REFS1 |
REFS0 |
|
ADLAR |
|
MUX4 |
MUX3 |
MUX2 |
MUX1 |
MUX0 |
ADMUX |
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|
• Bit 7, 6 – REFS1, REFS0: Reference Selection Bits
These bits select the voltage reference for the ADC, as shown in Table 36. If these bits are changed during a conversion, the change will not go in effect until this conversion is complete (ADIF in ADCSR is set). The user should disregard the first conversion result after changing these bits to obtain maximum accuracy. If differential channels are used, using AVCC or an external AREF higher than (AVCC - 0.2V) is not recommended, as this will affect ADC accuracy. The internal voltage reference may not be used if an external reference voltage is being applied to the AREF pin.
Table 36. Voltage Reference Selections for ADC
REFS1 |
REFS0 |
Voltage Reference Selection |
|
|
|
|
|
0 |
0 |
AVCC |
|
|
|
|
|
0 |
1 |
AREF (PA3), Internal Vref turned off. |
|
|
|
|
|
1 |
0 |
Internal Voltage Reference (2.56 V), AREF pin (PA3) not connected. |
|
|
|
|
|
1 |
1 |
Internal Voltage Reference (2.56 V) with external capacitor at AREF pin |
|
(PA3). |
|||
|
|
||
|
|
|
•Bit 5 – ADLAR: ADC Left Adjust Result
The ADLAR bit affects the presentation of the ADC conversion result in the ADC Data Register. If ADLAR is cleared, the result is right adjusted. If ADLAR is set, the result is left adjusted. Changing the ADLAR bit will affect the ADC Data Register immediately, regardless of any ongoing conversions. For a complete description of this bit, see “ADC Data Register – ADCL and ADCH” on page 87.
• Bits 4..0 – MUX4..MUX0: Analog Channel and Gain Selection Bits
The value of these bits selects which combination of analog inputs are connected to the ADC. These bits also select the gain for the differential channels. See Table 37 for details. If these bits are changed during a conversion, the change will not go in effect until this conversion is complete (ADIF in ADCSR is set).
84 ATtiny26(L)
1477B–AVR–04/02

ATtiny26(L)
Table 37. Input Channel and Gain Selections
|
Single Ended |
Positive Differential |
Negative Differential |
|
|
MUX4..0 |
Input |
Input |
Input |
Gain |
|
|
|
|
|
|
|
00000 |
ADC0 |
|
|
|
|
|
|
|
|
|
|
00001 |
ADC1 |
|
|
|
|
|
|
|
|
|
|
00010 |
ADC2 |
|
|
|
|
|
|
|
|
|
|
00011 |
ADC3 |
|
|
|
|
|
|
|
|
|
|
00100 |
ADC4 |
|
|
|
|
|
|
|
|
|
|
00101 |
ADC5 |
|
N/A |
|
|
|
|
|
|
|
|
00110 |
ADC6 |
|
|
|
|
|
|
|
|
|
|
00111 |
ADC7 |
|
|
|
|
|
|
|
|
|
|
01000 |
ADC8 |
|
|
|
|
|
|
|
|
|
|
01001 |
ADC9 |
|
|
|
|
|
|
|
|
|
|
01010 |
ADC10 |
|
|
|
|
01011 |
|
ADC0 |
ADC1 |
20x |
|
|
|
|
|
|
|
01100 |
|
ADC0 |
ADC1 |
1x |
|
|
|
|
|
|
|
01101(1) |
N/A |
ADC1 |
ADC1 |
20x |
|
01110 |
|
ADC2 |
ADC1 |
20x |
|
|
|
|
|
|
|
01111 |
|
ADC2 |
ADC1 |
1x |
|
10000 |
|
ADC2 |
ADC3 |
1x |
|
|
|
|
|
|
|
10001(1) |
N/A |
ADC3 |
ADC3 |
20x |
|
10010 |
ADC4 |
ADC3 |
20x |
||
|
|||||
|
|
|
|
|
|
10011(1) |
|
ADC4 |
ADC3 |
1x |
|
10100 |
|
ADC4 |
ADC5 |
20x |
|
|
|
|
|
|
|
10101 |
|
ADC4 |
ADC5 |
1x |
|
|
|
|
|
|
|
10110(1) |
N/A |
ADC5 |
ADC5 |
20x |
|
10111 |
|
ADC6 |
ADC5 |
20x |
|
|
|
|
|
|
|
11000 |
|
ADC6 |
ADC5 |
1x |
|
11001 |
|
ADC8 |
ADC9 |
20x |
|
|
|
|
|
|
|
11010 |
|
ADC8 |
ADC9 |
1x |
|
|
|
|
|
|
|
11011(1) |
N/A |
ADC9 |
ADC9 |
20x |
|
11100 |
|
ADC10 |
ADC9 |
20x |
|
|
|
|
|
|
|
11101 |
|
ADC10 |
ADC9 |
1x |
|
11110 |
1.18V (VBG) |
|
N/A |
|
|
|
|
|
|
||
11111 |
0V (GND) |
|
|
||
|
|
|
|||
Note: 1. |
For offset measurements only. See “Offset Compensation Schemes” on page 87. |
85
1477B–AVR–04/02

ADC Control and Status
Register – ADCSR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bit |
7 |
6 |
|
5 |
|
4 |
3 |
2 |
1 |
0 |
|
||
|
|
|
|
|
|
|
|
|
|
|
|
||
$06 ($26) |
ADEN |
ADSC |
|
ADFR |
|
ADIF |
ADIE |
ADPS2 |
ADPS1 |
ADPS0 |
ADCSR |
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|
• Bit 7 – ADEN: ADC Enable
Writing a logical “1” to this bit enables the ADC. By clearing this bit to zero, the ADC is turned off. Turning the ADC off while a conversion is in progress, will terminate this conversion.
• Bit 6 – ADSC: ADC Start Conversion
In Single Conversion mode, a logical “1” must be written to this bit to start each conversion. In Free Running mode, a logical “1” must be written to this bit to start the first conversion. The first time ADSC has been written after the ADC has been enabled, or if ADSC is written at the same time as the ADC is enabled, a dummy conversion will precede the initiated conversion. This dummy conversion performs initialization of the ADC.
ADSC will read as one as long as a conversion is in progress. When the conversion is complete, it returns to zero. When a dummy conversion precedes a real conversion, ADSC will stay high until the real conversion completes. Writing a 0 to this bit has no effect.
• Bit 5 – ADFR: ADC Free Running Select
When this bit is set (one) the ADC operates in Free Running mode. In this mode, the ADC samples and updates the Data Registers continuously. Clearing this bit (zero) will terminate Free Running mode.
• Bit 4 – ADIF: ADC Interrupt Flag
This bit is set (one) when an ADC conversion completes and the data registers are updated. The ADC Conversion Complete Interrupt is executed if the ADIE bit and the I- bit in SREG are set (one). ADIF is cleared by hardware when executing the corresponding interrupt handling vector. Alternatively, ADIF is cleared by writing a logical one to the flag. Beware that if doing a read-modify-write on ADCSR, a pending interrupt can be disabled. This also applies if the SBI and CBI instructions are used.
• Bit 3 – ADIE: ADC Interrupt Enable
When this bit is set (one) and the I-bit in SREG is set (one), the ADC Conversion Complete Interrupt is activated.
86 ATtiny26(L)
1477B–AVR–04/02