34 Temperature Sensor

An on-chip temperature sensor is available. To do a temperature measurement, the internal ADC peripheral acquires the sensor output. Using correction values from the System Controller (SYSCTRL) fuses, the application can calculate a temperature value in kelvin.

Follow these steps:
  1. Configure the ADC voltage reference to internal 2.048V by writing to the Reference Selection (REFSEL) bit field in the Control C register of the ADC (ADC.CTRLC).
  2. In the ADC Input Control (ADC.INPUTCTRL) register select the temperature sensor (TSENSE) as input in the Positive Input Multiplexer (MUXPOS) bit field.
  3. Configure the ADC Sample Length by writing a value ≥ 32 µs × f CLK_ADC to the Sample Length (SAMPLEN) bit field in the Control E (ADC.CTRLE) register.
  4. Acquire the temperature sensor output voltage by running a 12-bit single-ended conversion using the ADC.COMMAND register.
  5. Process the measurement result, as described below.
The measured voltage has a linear relationship to the temperature. Due to process variations, the temperature sensor output voltage varies between individual devices at the same temperature. The individual compensation factors determined during the production test are stored in these System Controller (SYSCTRL) fuses:
  • SYSCTRL.TEMPSENSE0 is a gain/slope correction
  • SYSCTRL.TEMPSENSE1 is an offset correction

The calibration values can be used to improve the accuracy of the result. To achieve even more accurate results, it is possible to perform further calibration. For example, multi-point calibration is performed by imposing known temperatures on the device and recording the ADC results. This helps create a precise calibration curve which can be implemented in firmware to adjust the output result.

Use the following equation to calculate the temperature (in kelvin):

T = ( Offset Correction ADC Result ) × Gain Correction 4096

Using the Calibration Values to Improve the Accuracy of the Temperature Readings

//Prerequisite: Configure ADC0 as described in the references

uint16_t sigrow_gain = SYSCTRL.TEMPSENSE0;    // Read unsigned gain/slope from System Controller fuse
int16_t sigrow_offset = SYSCTRL.TEMPSENSE1;   // Read signed offset from System Controller fuse

ADC_COMMAND_START  
while (!(ADC0->INTFLAG.reg & ADC_INTFLAG_RESRDY)) {
        // Wait for result ready
    }

uint16_t adc_reading = ADC0.RESULT >> 2;    // 10-bit MSb of ADC result with 2.048V internal reference 

uint32_t temp = adc_reading - sigrow_offset;
temp *= sigrow_gain;        // Result might overflow 16-bit variable (10-bit + 8-bit)
temp += 0x80;               // Add 256/2 to get correct integer rounding on division below
temp >>= 12;                 // Divide result by 4096 to get processed temperature in kelvin
uint16_t temperature_in_K = temp;
Refer to the Electrical Characteristics and the ADC - Analog-Digital Converter chapters for details on the configuration of the ADC for temperature measurements.