ATmega64A
where VIN is the voltage on the selected input pin and VREF the selected voltage reference (see
Table 23-3 on page 247 and Table 23-4 on page 248). 0x000 represents ground, and 0x3FF
represents the selected reference voltage minus one LSB.
If differential channels are used, the result is
(V
– V
) ⋅ GAIN ⋅ 512
NEG
POS
ADC = ------------------------------------------------------------------------
V
REF
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. The result is presented
in two’s complement form, from 0x200 (-512d) through 0x1FF (+511d). Note that if the user
wants to perform a quick polarity check of the results, it is sufficient to read the MSB of the result
(ADC9 in ADCH). If this bit is one, the result is negative, and if this bit is zero, the result is posi-
tive. Figure 23-14 shows the decoding of the differential input range.
Table 23-2 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
.
Figure 23-14. Differential Measurement Range
Output Code
0x1FF
0x000
0
Differential Input
Voltage (Volts)
- VREF/GAIN
0x3FF
V
REF/GAIN
0x200
246
8160C–AVR–07/09