This simple example shows how to use the Analog to Digital Converter (ADC) for temperature measurement with the internal sensor.
The ADC driver API can be found here.
All AVR XMEGA devices with an ADC can be used.
ADC A is configured for unsigned, 12-bit conversions using the VCC as 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 Celsius, is computed. The computation utilizes a linearization of the temperature data to calculate temperature in Celsius.
The computed temperature is stored in the global variable last_temperature, which is printed to the display, and can be watched during debugging.
This software was written for the GNU GCC and IAR for AVR. Other compilers may or may not work.
For further information, visit Microchip.