33.3.3.8 Temperature Measurement

An on-chip temperature sensor is available. Follow the steps below to do a temperature measurement. The resulting value will be right-adjusted.

  1. In the Voltage Reference (VREF) peripheral, select the internal 2.048V reference as the ADC reference voltage.
  2. Select the temperature sensor as input in the ADCn.MUXPOS register.
  3. Configure the Initialization Delay by writing a configuration ≥ 25 × fCLK_ADC µs to the Initialization Delay (INITDLY) bit field in the Control D (ADCn.CTRLD) register.
  4. Configure the ADC Sample Length by writing a configuration ≥ 28 µs × fCLK_ADC to the Sample Length (SAMPLEN) bit field in the SAMPCTRL (ADCn.SAMPCTRL) register.
  5. Acquire the temperature sensor output voltage by running a 12-bit, right-adjusted, single-ended conversion.
  6. Process the measurement result as described below.

The measured voltage has an almost linear relationship with 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 production test are stored in the Signature Row. These compensations factors are generated for the internal 2.048V reference.

  • SIGROW.TEMPSENSE0 contains the slope of the temperature sensor characteristics
  • SIGROW.TEMPSENSE1 contains the offset of the temperature sensor characteristics

In order to achieve more accurate results, the result of the temperature sensor measurement must be processed in the application software using compensation values from device production or user calibration. The temperature (in Kelvin) is calculated by the following equation:

T = ( Offset ADC Result ) × Slope 4096

It is recommended to follow these steps in the application code when using the compensation values from the Signature Row:

#define SCALING_FACTOR 4096 // Used to get a whole number in the signature row

uint16_t sigrow_offset = SIGROW.TEMPSENSE1; // Read unsigned offset from signature row
uint16_t sigrow_slope = SIGROW.TEMPSENSE0; // Read unsigned gain/slope from signature row
uint16_t adc_reading = ADCn.RES; // ADCn conversion result
    
uint32_t temp = sigrow_offset - adc_reading; 
temp *= sigrow_slope; // Result can overflow 16-bit variable
temp += SCALING_FACTOR / 2; // Ensures correct rounding on division below
temp /= SCALING_FACTOR; // Round off to nearest degree in Kelvin
uint16_t temperature_in_K = temp; 
int16_t temperature_in_C = temp - 273;

To increase the precision of the measurement to less than 1 Kelvin it is possible to adjust the last two steps to round off to a fraction of one degree. Add 4096/4 and right shift by 11 for a precision of ½ Kelvin, or add 4096/8 and right shift by 10 for a ¼ Kelvin precision.

If accumulation is used to reduce noise in the temperature measurement, the ADC result needs to be adjusted to a 12-bit value before the calculation is performed.

If another reference (VADCREF) than 2.048V is required, the offset and slope values need to be adjusted according to the following equations:

Slope = TEMPSENSE0 × V ADCREF 2.048 V
Offset = TEMPSENSE1 × 2.048 V V ADCREF