AT14164: User Calibration of Internal Temperature Sensor - SAM R21. Introduction. SMART ARM-based MCUs APPLICATION NOTE

Similar documents
AT15291: Migrating QTouch Designs from SAM D MCUs to SAM C MCUs. Scope. Features. QTouch APPLICATION NOTE

ATF15xx Power-On Reset Hysteresis Feature. Abstract. Features. Complex Programmable Logic Device APPLICATION NOTE

APPLICATION NOTE. AT11009: Migration from ATxmega64D3/128D3/192D3/256D3 Revision E to Revision I. Introduction. Features.

Introduction. Reference Documents. AFE Calibration on SAM V/E/S7x Microcontrollers. SMART ARM-based Microcontrollers APPLICATION NOTE

AVR221: Discrete PID Controller on tinyavr and megaavr devices. Introduction. AVR 8-bit Microcontrollers APPLICATION NOTE

APPLICATION NOTE. ATA6629/ATA6631 Development Board V2.2 ATA6629/ATA6631. Introduction

AVR122: Calibration of the AVR's internal temperature reference. 8-bit Microcontrollers. Application Note. Features.

APPLICATION NOTE. Atmel AVR127: Understanding ADC Parameters. Atmel 8-bit Microcontroller. Features. Introduction

QTouch Capacitive Touch Technology Copyright Atmel Atmel Corporation

8Mb (1M x 8) One-time Programmable, Read-only Memory

AT02598:Migration from AT86RF212 to AT86RF212B. Description. Features. Atmel MCU Wireless APPLICATION NOTE

ATA2526. Low-voltage IR Receiver ASSP DATASHEET. Features. Applications

Evaluation Kit ATA8520-EK1-F and Extension Board ATA8520-EK3-F (US Version) Kit Content ATAN0157 APPLICATION NOTE

AN12232 QN908x ADC Application Note

AN NHS3xxx Temperature sensor calibration. Document information

APPLICATION NOTE. AT11849: QTouch Surface Design Guide. Atmel QTouch. Introduction. Features

AN4014 Application Note Adjustable LED blinking frequency using a potentiometer and STM8SVLDISCOVERY Application overview

8-bit Microcontroller with 2K Bytes In-System Programmable Flash. ATtiny261A. Appendix A. Appendix A ATtiny261A Specification at 105 C

Flasher IC with 18-mΩ Shunt U6043B

APPLICATION NOTE. ATA6621, ATA6621N, ATA6622, ATA6622C, ATA6624, ATA6624C, ATA6626, ATA6626C Development Board ATA6621/22/24/26.

Atmel U6032B. Automotive Toggle Switch IC DATASHEET. Features. Description

Atmel ATA6629/ Atmel ATA6631 Development Board V2.2. Application Note. Atmel ATA6629/ATA6631 Development Board V

AVR42778: Core Independent Brushless DC Fan Control Using Configurable Custom Logic on ATtiny817. Features. Introduction. AVR 8-bit Microcontroller

AVR1311: Using the XMEGA Timer/Counter Extensions. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Flasher, 30 mω Shunt, Pilot Lamp to GND or V Batt U2043B

AVR1302: Using the XMEGA Analog Comparator. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Atmel LED Driver Technology. Smart LED Power Management for Efficiency, Programmability and Scalability

Low-cost Phase-control IC with Soft Start

Current Monitor IC U4793B

Flasher, 18-mΩ Shunt, Frequency Doubling Disabling U6433B

AN Energy Harvesting with the NTAG I²C and NTAG I²C plus. Application note COMPANY PUBLIC. Rev February Document information

Flasher IC with U643B

APPLICATION NOTE. ATA5279 Application Hints ATAN0003. Features. Description

UM DALI getting started guide. Document information

AN3332 Application note

ShortLink Wide Band Antenna Family Models: SLA150-SMA, SLA150-UFL. Wide Band Antenna Family SLA150 Datasheet

AN PR533 USB stick - Evaluation board. Application note COMPANY PUBLIC. Rev May Document information

R_ Driving LPC1500 with EPSON Crystals. Rev October Document information. Keywords Abstract

Technique for Measuring System Temperature Using the On-chip Temperature Sensor of the Z8 Encore! XP

AN2971 Application note

Normal Oscillator Behavior (Device A) Figure 1. Normal Oscillator Behavior (Device A) ft = f0 1 + TC1 T T0

UM DALI getting started guide. Document information

PN7120 NFC Controller SBC Kit User Manual

2.4 GHz 2.5 GHz FlexNotch 2 dbi Antenna w/u.fl Cable, 100mm

DATASHEET 4D SYSTEMS. Arduino Display Module Pack TURNING TECHNOLOGY INTO ART. Featuring a 2.4 Display Module ulcd-24-ptu-ar

AN12165 QN908x RF Evaluation Test Guide

TED-Kit 2, Release Notes

AN3397 Application note

UM User manual for di2c demo board. Document information

UM Slim proximity touch sensor demo board OM Document information

2.4 / 5.5 GHz FlexPIFA 3 dbi Antenna w/u.fl Cable, 100mm

ANTENNA DESIGN GUIDE. Last updated March 8 th, The information in this document is subject to change without notice.

2.4 GHz 2.5 GHz FlexPIFA 2 dbi Antenna w/u.fl Cable, 100mm

Low Voltage Brushed Motor System

SKY65120: WCDMA PA Bias Method For Lower Junction Temperature

Zero Bias Silicon Schottky Barrier Detector Diodes

TI Designs: Biometric Steering Wheel. Amy Ball TIDA-00292

T5753C. UHF ASK/FSK Transmitter DATASHEET. Features

AN3116 Application note

SMS : 0201 Surface Mount Low Barrier Silicon Schottky Diode Anti-Parallel Pair

PIN Diode Chips Supplied on Film Frame

UM Description of the TDA8029 I2C Demo Board. Document information

ANTENNA DESIGN GUIDE. Last updated February 11, The information in this document is subject to change without notice.

LF253, LF353. Wide bandwidth dual JFET operational amplifiers. Features. Description

DTH-14. High Accuracy Digital Temperature / Humidity Sensor. Summary. Applications. Data Sheet: DTH-14

UM10950 Start-up Guide for FRDM-KW41Z Evaluation Board Bluetooth Paring example with NTAG I²C plus Rev February

SMP1321 Series: Low Capacitance, Plastic Packaged PIN Diodes

TA75W01FU TA75W01FU. Dual Operational Amplifier. Features Pin Connection (Top View)

SKY LF: 300 khz 3 GHz Medium Power GaAs SPDT Switch

SMV LF and SMV LF: Surface Mount, 0402 Hyperabrupt Tuning Varactor Diodes

UM0791 User manual. Demonstration firmware for the DMX-512 communication protocol receiver based on the STM32F103Zx. Introduction

ACA4789: 1218 MHz 25 db Gain CATV Power-Doubler Amplifier

SKY LF: GaAs Digital Attenuator 5-Bit, 1 db LSB 400 MHz 4 GHz

UHF ASK/FSK Receiver ATA5721 ATA5722. Features

The Frequency Divider component produces an output that is the clock input divided by the specified value.

DATA SHEET SE2425U : 2.4 GHz Bluetooth Power Amplifier IC. Applications. Product Description. Features. Ordering Information

SMP1307 Series: Very Low Distortion Attenuator Plastic Packaged PIN Diodes

TIWI-R2 AND TIWI-BLE. Antenna Design Guide. Last updated February 10, The information in this document is subject to change without notice.

AN Maximum RF Input Power BGU6101. Document information. Keywords Abstract

SKY LF: PHEMT GaAs IC SP3T Switch GHz

AN UCODE I2C PCB antenna reference designs. Application note COMPANY PUBLIC. Rev October Document information

AA104-73/-73LF: 300 khz-2.5 GHz One-Bit Digital Attenuator

SKY , SKY LF: SP3T Switch for Bluetooth and b, g

2STA1695. High power PNP epitaxial planar bipolar transistor. Features. Applications. Description

ATA6140. Flasher Application Module. Application Note. ATA Flasher Application Module. 1. Description

ES_LPC1114. Errata sheet LPC1114. Document information

OM29110 NFC's SBC Interface Boards User Manual. Rev May

AN3101 Application note

AN Replacing HMC625 by NXP BGA7204. Document information

TOSHIBA Original CMOS 16-Bit Microcontroller. TLCS-900/H Series TMP95C061BFG TMP95C061BDFG. Semiconductor Company

TN LPC1800, LPC4300, MxMEMMAP, memory map. Document information

AN4112 Application note

Obsolete Product(s) - Obsolete Product(s)

EMIF06-MSD03F3. 6-line low capacitance IPAD for micro-sd card with EMI filtering and ESD protection. Features. Application. Description.

PN7150 Raspberry Pi SBC Kit Quick Start Guide

EVAL-RHF310V1. EVAL-RHF310V1 evaluation board. Features. Description

AN NFC, PN533, demo board. Application note COMPANY PUBLIC. Rev July Document information

Antenna Design Guide

SMS : 0201 Surface-Mount Low-Barrier Silicon Schottky Diode Anti-Parallel Pair

AVR055: Using a 32kHz XTAL for run-time calibration of the internal RC. 8-bit Microcontrollers. Application Note. Features.

Transcription:

SMART ARM-based MCUs AT14164: User Calibration of Internal Temperature Sensor - SAM R21 APPLICATION NOTE Introduction This application note explains about calibrating and compensating the errors of temperature measurements from the internal temperature sensor of Atmel SMART SAM R21. It provides the step-by-step information to: Store the calibration values in the NVM user row during production calibration Obtain an accurate temperature reading by compensating the temperature measurements using the calibration value, stored in the NVM user row The firmware package available with this application note contains the code implementation that supports the methods described in this application note. This code implementation can be used to obtain an accurate temperature reading.

Table of Contents Introduction...1 1. Internal Temperature Sensor of SAM R21...3 2. Compensating Internal Voltage Reference Variation... 4 2.1. Software-based Refinement of the Actual Temperature...4 2.2. Temperature Log Row... 4 2.3. Using Linear Interpolation...5 2.4. Temperature Sensor Output Across Temperature Range... 6 2.5. Temperature Sensor Output Across Temperature Range After Internal Voltage Reference Compensation... 7 3. Compensation for Offset and Gain Errors... 9 3.1. Two-point Calibration...9 4. User Calibration...14 4.1. Hardware Setup...14 4.2. Launching the Application... 14 4.3. Application Overview...15 5. Revision history... 17 2

1. Internal Temperature Sensor of SAM R21 The internal temperature sensor of SAM R21 can be used to determine an absolute temperature. The temperature sensor output can be routed to an ADC input channel by setting the bit TSEN (Bit 1 Voltage References System (VREF) Control). The ADC can be configured to measure this output voltage. The sensor will output a highly linear voltage proportional to the temperature. Due to process variations the output of the temperature sensor might vary from one chip to another. Also, the internal voltage reference used as the ADC reference voltage varies with the temperature. To obtain an accurate temperature reading from the internal temperature sensor, these variations must be compensated. The characteristics of the internal temperature sensor are as follows. Table 1-1 Temperature Sensor Characteristics Parameter Conditions Min. Typ. Max. Units Temperature sensor output voltage T= 25 C, V DDANA = 3.3V - 0.667 - V Temperature sensor slope 2.3 2.4 2.5 mv/ C Variation over V DDANA voltage V DDANA =1.8V to 3.6V -1.7 1 3.7 mv/v Temperature sensor accuracy Using the method described in Softwarebased Refinement of the Actual Temperature section of SAM R21 Datasheet. -10-10 C The upcoming topics describe the method to compensate the errors in temperature measurements using the internal temperature sensor. 3

2. Compensating Internal Voltage Reference Variation 2.1. Software-based Refinement of the Actual Temperature The temperature sensor behavior is linear but depends on several parameters such as the internal voltage reference, which itself depends on the temperature. To take this into account, each device contains a Temperature Log row with data measured and written during the production tests. These calibration values should be read by software to infer the most accurate temperature readings possible. This Software Temperature Log row can be read at address 0x00806030 This section specifies the Temperature Log row content and explains how to refine the temperature sensor output using the values in the Temperature Log row. 2.2. Temperature Log Row All values in this row were measured in the following conditions: V DDIN = V DDIO = V DDANA = 3.3V ADC Clock speed = 1MHz ADC mode: Free running mode, ADC averaging mode with 4 averaged samples ADC voltage reference = 1.0V internal reference (INT1V) ADC input = Temperature sensor Table 2-1 Temperature Log Row Content Bit position Name Description 7:0 ROOM_TEMP_VAL_INT Integer part of room temperature in C 11:8 ROOM_TEMP_VAL_DEC Decimal part of room temperature 19:12 HOT_TEMP_VAL_INT Integer part of hot temperature in C 23:20 HOT_TEMP_VAL_DEC Decimal part of hot temperature 31:24 ROOM_INT1V_VAL 2 s complement of the internal 1V reference drift at room temperature (versus a 1.0 centered value) 39:32 HOT_INT1V_VAL 2 s complement of the internal 1V reference drift at hot temperature (versus a 1.0 centered value) 51:40 ROOM_ADC_VAL 12-bit ADC conversion at room temperature 63:52 HOT_ADC_VAL 12-bit ADC conversion at hot temperature The temperature sensor values are logged during test production flow for Room and Hot insertions: ROOM_TEMP_VAL_INT and ROOM_TEMP_VAL_DEC contains the measured temperature at room insertion (e.g. for ROOM_TEMP_VAL_INT=25 and ROOM_TEMP_VAL_DEC=2, the measured temperature at room insertion is 25.2 C). HOT_TEMP_VAL_INT and HOT_TEMP_VAL_DEC contains the measured temperature at hot insertion (e.g. for HOT_TEMP_VAL_INT=83 and HOT_TEMP_VAL_DEC=3, the measured temperature at room insertion is 83.3 C). The temperature log row also contains the corresponding 12-bit ADC conversions of both Room and Hot temperatures: 4

ROOM_ADC_VAL contains the 12-bit ADC value corresponding to (ROOM_TEMP_VAL_INT, ROOM_TEMP_VAL_DEC) HOT_ADC_VAL contains the 12-bit ADC value corresponding to (HOT_TEMP_VAL_INT, HOT_TEMP_VAL_DEC) The temperature log row also contains the corresponding 1V internal reference of both Room and Hot temperatures: ROOM_INT1V_VAL is the 2 s complement of the internal 1V reference value corresponding to (ROOM_TEMP_VAL_INT, ROOM_TEMP_VAL_DEC) HOT_INT1V_VAL is the 2 s complement of the internal 1V reference value corresponding to (HOT_TEMP_VAL_INT, HOT_TEMP_VAL_DEC) ROOM_INT1V_VAL and HOT_INT1V_VAL values are centered around 1V with a 0.001V step. In other words, the range of values [0,127] corresponds to [1V, 0.873V] and the range of values [-1, -127] corresponds to [1.001V, 1.127V]. INT1V == 1 - (VAL/1000) is valid for both ranges. 2.3. Using Linear Interpolation For concise equations, we will use the following notations: (ROOM_TEMP_VAL_INT, ROOM_TEMP_VAL_DEC) is denoted temp R (HOT_TEMP_VAL_INT, HOT_TEMP_VAL_DEC) is denoted temp H ROOM_ADC_VAL is denoted ADC R, its conversion to Volt is denoted V ADCR HOT_ADC_VAL is denoted ADC H, its conversion to Volt is denoted V ADCH ROOM_INT1V_VAL is denoted INT1V R HOT_INT1V_VAL is denoted INT1V H Using the (temp R, ADC R ) and (temp H, ADC H ) points, using a linear interpolation we have the following equation: ADC + ADCR temp+ temp = ADCH + ADCR temp + temp Given a temperature sensor ADC conversion value ADC m, we can infer a coarse value of the temperature temp C as: temp = temp + ADC 1 2 12 + 1 ADC INT1 + ADC 2 12 + 1 INT1 2 12 + ADC + 1 temp + temp INT1 2 12 + 1 [Equation 1] Note: 1. In the previous expression, we have added the conversion of the ADC register value to be expressed in V. 2. This is a coarse value because we assume INT1V=1V for this ADC conversion. Using the (temp R, INT1V R ) and (temp H, INT1V H ) points, using a linear interpolation we have the following equation: INT1 + INT1 temp+ temp = INT1 + INT1 temp + temp 5

Then using the coarse temperature value, we can infer a closer to reality INT1V value during the ADC conversion as: INT1 = INT1 + INT1 + INT1 temp + temp temp + temp Back to [Equation 1], if we replace INT1V=1V by INT1V = INT1V m, we can deduce a finer temperature value as: temp = temp + [Equation 1bis] ADC INT1 INT1 2 12 + ADC + 1 2 12 temp temp + 1 INT1 INT1 ADC 2 12 + ADC + 1 2 12 + 1 2.4. Temperature Sensor Output Across Temperature Range The following plot shows the ADC output of temperature sensor, without any compensation, plotted over the temperature range. The measurements were recorded with the configurations specified in Temperature Log Row. Figure 2-1 ADC Output vs. Temperature From the preceding plot, it is observed that the output of temperature sensor is linear with increase in temperature. Note: The graphical plots presented in the upcoming sections were all recorded using the same SAM R21 device to demonstrate the improvement of accuracy with each step of compensation. The improvement of accuracy was observed in 6 different SAM R21 devices. 6

2.5. Temperature Sensor Output Across Temperature Range After Internal Voltage Reference Compensation The following plot shows the temperature value read from the sensor s output across the operating temperature range. This measurement uses the software based refinement method. These temperature measurement values are compensated for the variation in internal voltage reference. For easier comparison, the ideal temperature has also been plotted. Figure 2-2 Measured Temperature (after Internal Voltage Reference Compensation) vs. Temperature From this plot, we infer the variation of measurement error across the operating temperature range. This error can be mathematically represented as, T error = T ideal - T measured The error in measured temperature has been plotted in the following figure over the temperature range. It is observed from the plot, that the measurement error varies from -10 C to 5 C. 7

Figure 2-3 Error in Measured Temperature (after Internal Voltage Reference Compensation) vs. Temperature 8

3. Compensation for Offset and Gain Errors The results from temperature measurements have offset and gain errors. These errors in the measured temperature value can be compensated by making calibration measurements at two known temperatures. From these measurements, offset and gain error in the temperature measurements can be calculated. Compensating the measured temperature for offset and gain error can result in very precise temperature measurements, sometime as accurate as ±3 C. This section explains about the two-point calibration process in detail. 3.1. Two-point Calibration To measure the temperature as accurate as possible, two calibration points are required. Let us consider these two points as T1 and T2. In the associated application, T1 and T2 are configured as 25 C and 80 C, respectively. The second calibration temperature must be chosen a little higher than the desired temperature range. After compensating the internal voltage reference variation, Let ADC_T1 be the measured value of the temperature(in C), at the first calibration point (T1) Let ADC_T2 be the measured value of the temperature(in C), at the second calibration point (T2) Note: The Two-point calibration can be applied to get an accurate temperature reading, only if the output from temperature sensor is linear. 3.1.1. Calculating the Offset Error Let us plot a graph with X-axis as the temperature during the actual measurement and Y-axis as the temperature measured from ADC. Let the origin for the plot be (0,0). Plot a straight line defined by the two points (T1,ADC_T1) and (T2,ADC_T2). Let us mark a point (X,Y) in the line. The slope of this line will be defined by the following equation, _ 2 _ 1 = 2 1 From the above equation, = _ 1 + = _ 1 1 1 _ 2 _ 1 2 1 9

Figure 3-1 Measured Temperature (after Internal Voltage Reference Compensation) vs. Temperature Ideally, at X=0, the value of Y must be equal to 0 (Y=0). But, the above plot is affected by an offset error (T_Offset). This error is the distance between the origin of coordinates and the point where the line defined by the two calibration points intersects the Y-axis i.e.,y-intercept of the line defined by the two calibration points, which can be found by substituting X=0 in the above equation. The resultant offset error can be calculated by, _ = _ 1 + 1 _ 2 _ 1 2 1 3.1.2. Calculating the Gain Error The following figure shows the plot of measured temperature value after compensating the offset error. It can be observed that the plot is still affected by gain error. 10

Figure 3-2 Measured Temperature (after Internal Voltage Reference and Offset Error Compensation) vs. Temperature It is necessary to find the gain factor(k) that affects the measured temperature value. Gain error is the ratio of Ideal Temperature value to that of the Measured temperature, after offset error compensation. The gain error is mathematically represented by, 2 = _ 2 _ Note: The value of k will not vary even if T2 is replaced with T1 and ADC_T2 is replaced with ADC_T1 in the above equation, as both the points lie in the same straight line. 3.1.3. Offset and Gain Error Compensation The measured temperature value can be compensated for Offset and gain error using the following equation. _ = _ _ * Where, T_ADC is measured temperature value after internal voltage reference compensation T_c is the measured temperature value after internal voltage reference compensation, offset and gain error compensation The following plot shows the measured temperature value after internal voltage reference compensation, offset and gain error compensation. 11

Figure 3-3 Measured Temperature (after Internal Voltage Reference compensation, Offset and Gain Error Compensation) vs. Temperature 3.1.4. Accuracy After Internal Voltage Reference, Offset and Gain Error Compensation After compensating the measured temperature value for variation in internal voltage reference, offset error and gain error, the accuracy of the measured temperature value can be as high as ±3 C. The error in measured temperature after offset and gain error compensation can be found from the below plot. The red arrow along the Y-axis indicates the span of the error before offset and gain error compensation. The blue arrow along the Y-axis indicates the span of the error after offset and gain error compensation. 12

Figure 3-4 Error in Measured Temperature (after Internal Voltage Reference, Offset and Gain Error Compensation) vs. Temperature 13

4. User Calibration The firmware package available with this application note contains an Atmel Studio project (AT14164.atsln). This project shows the implementation of software-based refinement and two-point calibration process described in this application note. This project uses Atmel Software Framework (ASF V3.25.0). Steps to calibrate the internal temperature sensor of SAM R21 using this firmware is explained in the upcoming topics. 4.1. Hardware Setup 1 * SAM R21 Xplained Pro Board 1 * Temperature controlled chamber 4.2. Launching the Application To launch the default application, 1. Open the Atmel studio project (AT14164.atsln) in Atmel studio. 2. Compile the project and program the image generated from the project to the SAM R21 Xplained Pro board. 3. Place the programmed SAM R21 Xplained Pro board in a temperature controlled chamber. 4. Connect the SAM R21 Xplained Pro board to the PC-Terminal Application (e.g. TeraTerm) using a Micro-USB cable connected to the EDBG USB header of the board. Use the following setting for the serial connection with the PC-terminal: BAUD RATE: 115200 PARITY: None DATA BITS: 8 STOP BITS: 1 FLOW CONTROL: None 5. Press any key from the PC-terminal application, to start the application. 6. The application would load the data from the temperature log row of SAM R21. 7. Set the temperature to be 25 C and wait for some time (e.g. 10-20 minutes) for the board to settle. 8. Press any key from the PC-terminal application to proceed further. The application will read the temperature sensor s output at this moment and store the measured temperature to a variable ADC_T1 in the application. 9. Set the temperature to 80 C and wait for some time (e.g. 10-20 minutes) for the board to settle. 10. Press any key from the PC-terminal application to proceed further. The application will read the temperature sensor s output at this moment and store the measured temperature to a variable ADC_T2 in the application. The application will calculate the Offset (T_offset) and Gain(k) error in the measured temperature value. The calculated error values will be stored in NVM user row at the address 0x00804008. 11. The application will measure the temperature sensor output every 5 seconds and initiate the compensation process. The offset and gain error value will be read from the NVM user row. The read values will be used for compensating the measured temperature value for the offset and gain error. The measured temperature value after compensation will be printed in the terminal window. 14

The example PC-terminal window showing the message logs can be found below. In the terminal window, T_c corresponds to the measured temperature value after compensations (in C). Figure 4-1 Example PC-terminal Window 4.3. Application Overview This topic describes the major functions used in the application project. The default application project runs with internal 8MHz oscillator of SAM R21. The following code snippet shows the main() function of the application: int main(void) { system_init(); delay_init(); /*Serial Console configuration */ configure_console(); /*NVM configuration*/ configure_nvm(); /*ADC Configuration*/ configure_adc(); /*Enter any character from the terminal to start the application*/ getchar(); /*Load the data from the Temperature Log row */ load_temperature_log_row_data(); /*Initiate the user calibration process*/ adc_temp_sensor_calibration(); while (1) { adc_temp_sensor(); 15

} } delay_s(5); calculate_temperature(): This function will compensate the measured temperature value for the variation in internal voltage reference. This function implements the procedure mentioned in the section Software-based Refinement of the Actual Temperature. This function is available in the adc_temp.c file of the firmware package. load_temperature_log_row_data(): This function reads the contents of the temperature log row and stores it to global variables. This function is available in the adc_temp.c file of the firmware package. The stored values will be used in calculate_temperature() function. nvm_set_calibration_fuse(): This function will write the NVM user row at address 0x00804008 with the offset and gain error calculated. This function is available in the main.c file of the firmware package. This function will mask the contents of NVM user row containing the fuse bits (0x00804000). adc_temp_sensor_calibration: This function will calculate the values of offset and gain error on the measured temperature value by implementing the two-point calibration procedure mentioned in Compensation for Offset and Gain Errors on page 9. This function is available in the main.c file of the firmware package. The calculated values of offset and gain error will be stored in the NVM user row using the function nvm_set_calibration_fuse(). adc_temp_sensor: This function will read the temperature sensor output at the given moment and call calculate_temperature() function to compensate the measured temperature value for the variation in internal voltage reference. This function is available in the main.c file of the firmware package. After this, the measured temperature value will be compensated for the offset and gain error, read from the NVM user row at address 0x00804008. The final result will be printed in the terminal window of the PC. configure_adc(): The function configures the ADC module with the configuration parameters mentioned in the Temperature Log Row except for the averaging configuration. In this function, ADC is configured to operate in averaging mode with 64 samples to decrease the volatility in the temperature sensor output. This function is available in main.c file of the firmware package associated with this application note. The application can be modified to change the first and second calibration point. In the default application project, first calibration point is fixed to 25 C and second calibration point is fixed to 80 C. This can be modified by changing the values of the variables T1 and T2 in adc_temp_sensor_calibration() function of main.c file. If the operating frequency of the application has to be modified, ADC prescaler configuration in configure_adc() function needs to be modified such that the configuration of ADC mentioned in Compensating Internal Voltage Reference Variation on page 4 is not modified. In addition to this, other parameters like flash wait states also needs to be taken care by the user. 16

5. Revision history Doc Rev. Date Comments 42561A 11/2015 Initial document release 17

Atmel Corporation 1600 Technology Drive, San Jose, CA 95110 USA T: (+1)(408) 441.0311 F: (+1)(408) 436.4200 www.atmel.com 2015 Atmel Corporation. / Rev.: Atmel, Atmel logo and combinations thereof, Enabling Unlimited Possibilities, and others are registered trademarks or trademarks of Atmel Corporation in U.S. and other countries. ARM, ARM Connected logo, and others are the registered trademarks or trademarks of ARM Ltd. Other terms and product names may be trademarks of others. DISCLAIMER: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS AND PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and products descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life. SAFETY-CRITICAL, MILITARY, AND AUTOMOTIVE APPLICATIONS DISCLAIMER: Atmel products are not designed for and will not be used in connection with any applications where the failure of such products would reasonably be expected to result in significant personal injury or death ( Safety-Critical Applications ) without an Atmel officer's specific written consent. Safety-Critical Applications include, without limitation, life support devices and systems, equipment or systems for the operation of nuclear facilities and weapons systems. Atmel products are not designed nor intended for use in military or aerospace applications or environments unless specifically designated by Atmel as military-grade. Atmel products are not designed nor intended for use in automotive applications unless specifically designated by Atmel as automotive-grade.