beautypg.com

Figure 51 s, Table 35, Attiny26(l) – Rainbow Electronics ATtiny26L User Manual

Page 83

background image

83

ATtiny26(L)

1477B–AVR–04/02

Figure 51. Differential Measurement Range

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.

Table 35. Correlation Between Input Voltage and Output Codes

V

ADCn

Read code

Corresponding decimal value

V

ADCm

+ V

REF

/GAIN

0x3FF

1023

V

ADCm

+ 0.999 V

REF

/GAIN

0x3FF

1023

V

ADCm

+ 0.998 V

REF

/GAIN

0x3FE

1022

...

...

...

V

ADCm

+ 0.001 V

REF

/GAIN

0x001

1

V

ADCm

0x000

0

0

Output Code

0x3FF

0x000

V

REF

/GAIN

Differential Input
Voltage (Volts)