ATmega169P
Table 21-2. Correlation Between Input Voltage and Output Codes
VADCn
Read Code
0x1FF
0x1FF
0x1FE
...
Corresponding Decimal Value
VADCm + VREF
511
511
510
...
511
VADCm
VADCm
...
+
+
/
512 VREF
510
/512 VREF
V
ADCm + 1/512 VREF
VADCm
ADCm - 1/512 VREF
0x001
0x000
0x3FF
...
1
0
V
-1
...
...
511
VADCm
-
/
512 VREF
0x201
0x200
-511
-512
V
ADCm - VREF
ADMUX = 0xFB (ADC3 - ADC2, 1.1V reference, left adjusted result)
Voltage on ADC3 is 300 mV, voltage on ADC2 is 500 mV.
ADCR = 512 * (300 - 500) / 1100 = -93 = 0x3A3.
ADCL will thus read 0xC0, and ADCH will read 0xD8. Writing zero to ADLAR right adjusts the
result: ADCL = 0xA3, ADCH = 0x03.
227
8018A–AVR–03/06