29.3.2.6 Temperature Measurement

The temperature measurement is based on an on-chip temperature sensor. For temperature measurement, follow these steps:
  1. Configure the internal voltage reference to 1.1V by configuring the VREF peripheral.
  2. Select the internal voltage reference by writing the REFSEL bit field in ADCn.CTRLC register to 0x0.
  3. Select the ADC temperature sensor channel by configuring the MUXPOS (ADCn.MUXPOS) register. This enables the temperature sensor.
  4. In ADCn.CTRLD select INITDLY 32 µs × f CLK_ADC .
  5. In ADCn.SAMPCTRL select SAMPLEN 32 µs × f CLK_ADC .
  6. In ADCn.CTRLC select SAMPCAP = 1 .
  7. Acquire the temperature sensor output voltage by starting a conversion.
  8. 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 are determined during the production test and saved in the Signature Row:
  • SIGROW.TEMPSENSE0 is a gain/slope correction
  • SIGROW.TEMPSENSE1 is an offset correction

To achieve accurate results, the result of the temperature sensor measurement must be processed in the application software using factory calibration values. The temperature (in Kelvin) is calculated by this rule:

Temp = (((RESH << 8) | RESL) - TEMPSENSE1) * TEMPSENSE0) >> 8

RESH and RESL are the high and low bytes of the Result (ADCn.RES) register, and TEMPSENSEn are the respective values from the Signature row.

It is recommended to follow these steps in user code:

int8_t sigrow_offset = SIGROW.TEMPSENSE1;  // Read signed value from signature row
uint8_t sigrow_gain = SIGROW.TEMPSENSE0;    // Read unsigned value from signature row
uint16_t adc_reading = ADCn.RES;   // ADC conversion result with 1.1 V internal reference 

uint32_t temp = adc_reading - sigrow_offset;
temp *= sigrow_gain;  // Result might overflow 16 bit variable (10bit+8bit)
temp += 0x80;               // Add 1/2 to get correct rounding on division below
temp >>= 8;                 // Divide result to get Kelvin 
uint16_t temperature_in_K = temp;