Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ADC Internal temperature sensor example for XMEGA-A1 Xplained Documentation

Introduction

This simple example shows how to use the Analog to Digital Converter (ADC) for temperature measurement with the internal sensor.

Main files:

ADC driver API

The ADC driver API can be found here.

Device Info

All AVR XMEGA devices with an ADC can be used.

Description of the example

ADC A is configured for unsigned, 12-bit conversions using the internal 1 V voltage reference. The conversions are configured for manual triggering. Channel 0 of the ADC is configured for single-ended measurements from the internal temperature sensor.

An ADC interrupt callback function is used to handle the conversion results, from which the current temperature, in kelvin, is computed. The computation requires the factory calibration measurement, and is done according to the following formula (T = temperature, R = ADC result):

\[ T_\textnormal{now} = \frac{(R_\textnormal{now} \cdot T_\textnormal{calibration})}{R_\textnormal{calibration}} \]

The computed temperature is stored in the global variable last_temperature, which can, e.g., be watched during debugging.

Compilation Info

This software was written for the GNU GCC and IAR for AVR. Other compilers may or may not work.

Contact Information

For further information, visit Microchip.