
109
ATtiny40 [DATASHEET]
8263B–AVR–01/2013
15.11 ADC Conversion Result
After the conversion is complete (ADIF is high), the conversion result can be found in the ADC Data Registers
(ADCL, ADCH). The result is, as follows:
where V
IN is the voltage on the selected input pin and VREF the selected voltage reference (see Table 15-3 on page voltage minus one LSB. The result is presented in one-sided form, from 0x3FF to 0x000.
15.12 Temperature Measurement
The temperature measurement is based on an on-chip temperature sensor that is coupled to a single ended ADC
channel. The temperature sensor is measured via channel ADC12 and is enabled by writing MUX bits in ADMUX
register to “1110”. The internal 1.1V reference must also be selected for the ADC reference source in the tempera-
ture sensor measurement. When the temperature sensor is enabled, the ADC converter can be used in single
conversion mode to measure the voltage over the temperature sensor.
The measured voltage has a linear relationship to the temperature as described in
Table 15-2 The sensitivity is
approximately 1 LSB /
C and the accuracy depends on the method of user calibration. Typically, the measurement
accuracy after a single temperature calibration is ±10
C, assuming calibration at room temperature. Better
accuracies are achieved by using two temperature points for calibration.
The values described in
Table 15-2 are typical values. However, due to process variation the temperature sensor
output voltage varies from one chip to another. To be capable of achieving more accurate results the temperature
measurement can be calibrated in the application software. The sofware calibration can be done using the formula:
T = k * [(ADCH << 8) | ADCL] + T
OS
where ADCH and ADCL are the ADC data registers, k is the fixed slope coefficient and T
OS is the temperature sen-
sor offset. Typically, k is very close to 1.0 and in single-point calibration the coefficient may be omitted. Where
higher accuracy is required the slope coefficient should be evaluated based on measurements at two
temperatures.
15.13 Register Description
15.13.1
ADMUX – ADC Multiplexer Selection Register
Bit 7 – Res: Reserved Bit
This bit is reserved and will always read as zero.
ADC
VIN 1024
VREF
--------------------------
=
Table 15-2.
Temperature vs. Sensor Output Voltage (Typical Case)
Temperature
-40
C+25C+85C
ADC
230 LSB
300 LSB
370 LSB
Bit
765
432
10
–
REFS
REFEN
ADC0EN
MUX3
MUX2
MUX1
MUX0
ADMUX
Read/Write
R
R/W
Initial Value
000
00