Microchip Technology megaAVR 0 Series Manual page 419

Hide thumbs Also See for megaAVR 0 Series:
Table of Contents

Advertisement

SIGROW.TEMPSENSE1 is an offset correction
In order to achieve accurate results, the result of the temperature sensor measurement must be
processed in the application software using factory calibration values. The temperature (in Kelvin) is
calculated by this rule:
Temp = (((RESH << 8) | RESL) - TEMPSENSE1) * TEMPSENSE0) >> 8
RESH and RESL are the high and low bytes of the Result register (ADCn.RES), and TEMPSENSEn are
the respective values from the Signature row.
It is recommended to follow these steps in user code:
int8_t
sigrow_offset = SIGROW.TEMPSENSE1;
uint8_t
sigrow_gain = SIGROW.TEMPSENSE0;
uint16_t
adc_reading = 0;
uint32_t
temp = adc_reading - sigrow_offset;
temp *= sigrow_gain;
temp += 0x80;
temp >>= 8;
uint16_t
temperature_in_K = temp;
28.3.2.7 Window Comparator Mode
The ADC can raise the WCOMP flag in the Interrupt and Flag register (ADCn.INTFLAG) and request an
interrupt (WCOMP) when the result of a conversion is above and/or below certain thresholds. The
available modes are:
The result is under a threshold
The result is over a threshold
The result is inside a window (above a lower threshold, but below the upper one)
The result is outside a window (either under the lower or above the upper threshold)
The thresholds are defined by writing to the Window Comparator Threshold registers (ADCn.WINLT and
ADCn.WINHT). Writing to the Window Comparator mode bit field (WINCM) in the Control E register
(ADCn.CTRLE) selects the conditions when the flag is raised and/or the interrupt is requested.
Assuming the ADC is already configured to run, follow these steps to use the Window Comparator mode:
1.
Choose which Window Comparator to use (see the WINCM description in ADCn.CTRLE), and set
the required threshold(s) by writing to ADCn.WINLT and/or ADCn.WINHT.
2.
Optional: enable the interrupt request by writing a '1' to the Window Comparator Interrupt Enable bit
(WCOMP) in the Interrupt Control register (ADCn.INTCTRL).
3.
Enable the Window Comparator and select a mode by writing a non-zero value to the WINCM bit
field in ADCn.CTRLE.
When accumulating multiple samples, the comparison between the result and the threshold will happen
after the last sample was acquired. Consequently, the flag is raised only once, after taking the last sample
of the accumulation.
28.3.3
Events
An ADC conversion can be triggered automatically by an event input if the Start Event Input bit
(STARTEI) in the Event Control register (ADCn.EVCTRL) is written to '1'.
See also the description of the Asynchronous User Channel n Input Selection in the Event System
(EVSYS.ASYNCUSERn).
©
2018 Microchip Technology Inc.
// Read signed value from signature row
// Read unsigned value from signature row
// ADC conversion result with 1.1 V internal reference
// Result might overflow 16 bit variable (10bit+8bit)
// Add 1/2 to get correct rounding on division below
// Divide result to get Kelvin
Datasheet Preliminary
megaAVR
Analog-to-Digital Converter (ADC)
DS40002015A-page 419
®
0-Series

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the megaAVR 0 Series and is the answer not in the manual?

This manual is also suitable for:

Atmega4808Atmega4809Atmega3208Atmega3209

Table of Contents