226
ATmega16M1/32M1/64M1 [DATASHEET]
8209E–AVR–11/2012
Example 1:
– ADMUX = 0xED (ADC3 - ADC2, 10× gain, 2.56V reference, left adjusted result)
– Voltage on ADC3 is 300mV, voltage on ADC2 is 500mV
– ADCR = 512 × 10 × (300 - 500)/2560 = -400 = 0x270
– ADCL will thus read 0x00, and ADCH will read 0x9C
Writing zero to ADLAR right adjusts the result: ADCL = 0x70, ADCH = 0x02.
Example 2:
– ADMUX = 0xFB (ADC3 - ADC2, 1× gain, 2.56V reference, left adjusted result)
– Voltage on ADC3 is 300mV, voltage on ADC2 is 500mV
– ADCR = 512 × 1 × (300 - 500)/2560 = -41 = 0x029
– ADCL will thus read 0x40, and ADCH will read 0x0A
Writing zero to ADLAR right adjusts the result: ADCL = 0x00, ADCH = 0x29.
21.8
Temperature measurement
The temperature measurement is based on an on-chip temperature sensor that is coupled to a single ended ADC
input. MUX[4:0] bits in ADMUX register enables the temperature sensor. The internal 2.56V voltage reference
must also be selected for the ADC voltage reference source in the temperature 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 21-3 The sensitivity is
approximately 2.5mV/
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.
Table 21-2.
Correlation between input voltage and output codes.
V
ADCn
Read code
Corresponding decimal value
VADCm + VREF /GAIN
0x1FF
511
V
ADCm + 0.999 VREF /GAIN
0x1FF
511
VADCm + 0.998 VREF /GAIN
0x1FE
510
...
V
ADCm + 0.001 VREF /GAIN
0x001
1
VADCm
0x000
0
VADCm - 0.001 VREF /GAIN
0x3FF
-1
...
VADCm - 0.999 VREF /GAIN
0x201
-511
VADCm - VREF /GAIN
0x200
-512
Table 21-3.
Temperature vs. sensor output voltage (typical case): Example ADC values.
Temperature
–40°C
+25°C
+85°C
Voltage
600mV
762mV
912mV