9 internal temperature measurement, Table 27-7 on, Atmega128rfa1 – Rainbow Electronics ATmega128RFA1 User Manual
Page 425

425
8266A-MCU Wireless-12/09
ATmega128RFA1
Table 27-7. Correlation Between Input Voltage and Output Codes
V
ADCn
Read Code
Corresponding Decimal Value
V
ADCm
+ V
REF
/ GAIN
0x1FF
511
V
ADCm
+ 0.999 V
REF
/ GAIN
0x1FF
511
V
ADCm
+ 0.998 V
REF
/ GAIN
0x1FE
510
…
…
…
V
ADCm
+ 0.001 V
REF
/ GAIN
0x001
1
V
ADCm
0x000
0
V
ADCm
- 0.001 V
REF
/ GAIN
0x3FF
-1
…
…
…
V
ADCm
- 0.999 V
REF
/ GAIN
0x201
-511
V
ADCm
- V
REF
/ GAIN
0x200
-512
Example:
ADMUX = 0xED (ADC3 - ADC2, 10x gain, 1.6V reference, left adjusted result)
The voltage on ADC3 is 300 mV; the voltage on ADC2 is 425 mV.
ADCR = 512 * 10 * (300 - 425) / 1600 = -400 = 0x270.
ADCL will thus read 0x00, and ADCH will read 0x9C. Writing zero to ADLAR right
adjusts the result: ADCL = 0x70, ADCH = 0x02.
27.9 Internal Temperature Measurement
The on-chip temperature can be measured using a special setup of the A/D converter
inputs. The integrated temperature sensor provides a linear, medium-accurate voltage
proportional to the absolute temperature (in Kelvin). This voltage is first amplified with
the programmable gain amplifier and then processed with the A/D converter. A low
frequency of the conversion clock must be selected due to the nature of the input
signal. The absolute accuracy of the temperature measurement is limited by
manufacturing tolerances, noise from supply and ground voltages and the exactness of
the reference voltage. The following table summarizes the preferred setup of the
temperature measurement:
Table 27-8. Recommended ADC Setup for Temperature Measurement
Parameter
Register
Recommended Setup
ADC Channel
ADMUX,
ADCSRB
Select the Temperature Sensor, MUX4:0 = 01001;
MUX5 = 1;
ADC Clock
ADCSRA
Select a clock frequency of 500kHz or lower;
V
REF
ADMUX
Select the internal 1.6V reference voltage;
Start-up time
ADCSRC
Standard requirement of 20µs is sufficient;
Tracking time
ADCSRC
Setting ADTHT = 0 is sufficient;
The A/D conversion result ADC
TEMP
will always be a positive number. The ideal result
can be calculated when using the internal 1.6V reference voltage according to the
following equation:
C
ADC
TEMP
°
⋅
+
=
/
885
.
0
4
.
241
θ
Similar the Celsius-temperature θ can be extracted from the A/D conversion result with
this formula: