41.6.3.2 Device Temperature Measurement
Principle
The device has an integrated temperature sensor which is part of the Supply Controller (SUPC). The analog signal of that sensor can be converted into a digital value by the ADC. The digital value can be converted into a temperature in °C by following the steps in this section.
Configuration and Conditions
- Configure the clocks and device frequencies according to the Electrical Characteristics chapters.
- Configure the Voltage References System of the Supply Controller (SUPC):
- Enable the temperature sensor by writing a '1' to the Temperature Sensor Enable bit in the VREF Control register (SUPC.VREF.TSEN).
- Select the required voltage for the internal voltage reference INTREF by writing to the Voltage Reference Selection bits (SUPC.VREF.SEL). The required value can be found in the Electrical Characteristics chapters.
- Enable routing INTREF to the ADC by writing a '1' to the Voltage Reference Output Enable bit (SUPC.VREF.VREFOE).
- Configure the ADC:
- Select the internal voltage reference INTREF as ADC reference voltage by writing to the Reference Control register (ADC.REFCTRL.REFSEL).
- Select the temperature sensor vs. internal GND as input by writing TEMP and GND to the positive and negative MUX Input Selection bit fields (ADC.INPUTCTRL.MUXNEG and .MUXPOS, respectively).
- Configure the remaining ADC parameters according to the Electrical Characteristics chapters.
- Enable the ADC and acquire a value, ADCm.
Calculation Parameter Values
The temperature sensor behavior is linear, but it is sensitive to 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 individual calibration data measured and written during the production tests. These calibration values are read by software to infer the most accurate temperature readings possible.
- Calibration temperatures in
°C. One at room temperature tempR, one at a higher
temperature tempH:
- ROOM_TEMP_VAL_INT and ROOM_TEMP_VAL_DEC contain the measured
temperature at room insertion, tempR, in °C,
separated in integer and decimal value.
Example: For ROOM_TEMP_VAL_INT=0x19=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 contain the measured temperature at hot insertion, tempH, in °C. The integer and decimal value are also separated.
- ROOM_TEMP_VAL_INT and ROOM_TEMP_VAL_DEC contain the measured
temperature at room insertion, tempR, in °C,
separated in integer and decimal value.
- For each temperature, the
corresponding sensor value at the ADC in 12-bit, ADCR and
ADCH:
- ROOM_ADC_VAL contains the 12-bit ADC value, ADCR, corresponding to tempR. Its conversion to Volt is denoted VADCR.
- HOT_ADC_VAL contains the 12-bit ADC value, ADCH, corresponding to tempH. Its conversion to Volt is denoted VADCH.
- Actual reference voltages at
each calibration temperature in Volt, INT1VR and INT1VH,
respectively:
- ROOM_INT1V_VAL is the 2’s complement of the internal 1V reference value at tempR: INT1VR.
- HOT_INT1V_VAL is the 2’s complement of the internal 1V reference value at tempH: INT1VH.
- Both 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.
Calculating the Temperature by Linear Interpolation
Using the data pairs (tempR, VADCR) and (tempH, VADCH) for a linear interpolation, we have the following equation:
The voltages Vx are acquired as 12-bit ADC values ADCx, with respect to an internal reference voltage INT1Vx:
[Equation 1]For the measured value of the temperature sensor, ADCm, the reference voltage is assumed to be perfect, i.e., INT1Vm=INT1Vc=1V. These substitutions yield a coarse value of the measured temperature tempC:
[Equation 2]Or, after eliminating the 12-bit scaling factor (212-1):
[Equation 3]
Equations 3 is a coarse value, because we assumed that INT1Vc=1V. To achieve a more accurate result, we replace INT1Vc with an interpolated value INT1Vm. We use the two data pairs (tempR, INT1VR) and (tempH, INT1VH) and yield:
Using the coarse temperature value tempc, we can infer a more precise INT1Vm value during the ADC conversion as:
[Equation 4]Back to Equation 3, we replace the simple INT1Vc=1V by the more precise INT1Vm of Equation 4, and find a more accurate temperature value tempf:
[Equation 5]