Temperature Measurement

An on-chip temperature sensor is available. To do a temperature measurement, follow these steps:
  1. 1.Configure the voltage reference to internal 1.024V by writing to the Reference Selection (REFSEL) bit field the ADCn.CTRLC register.
  2. 2.Select the temperature sensor as input in the Positive Input Multiplexer (ADCn.MUXPOS) register.
  3. 3.Configure the ADC Sample Duration by writing a value ≥ 32µs×fCLK_ADC to the Sample Duration (SAMPDUR) bit field in the Control E (ADCn.CTRLE) register.
  4. 4.Acquire the temperature sensor output voltage by running a 12-bit Single-Ended conversion.
  5. 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 the individual devices at the same temperature. The individual compensation factors determined during the production test are stored in the Signature Row: The result of the temperature sensor measurement must be processed in the application software using compensation values from device production or user calibration to achieve more accurate results. Refer to the Electrical Characteristics section for further details.

The following equation gives the temperature (in Kelvin):

T=(ADC ResultOffset Correction)×Gain Correction256
It is recommended to follow these steps in the user code when using the compensation values from the Signature Row:
int8_t sigrow_offset = SIGROW.TEMPSENSE1;   // Read signed offset from signature row
uint8_t sigrow_gain = SIGROW.TEMPSENSE0;    // Read unsigned gain/slope from signature row
uint16_t adc_reading = ADC0.RESULT >> 2;    // 10-bit MSb of ADC result with 1.024V 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 >>= 8;                 // Divide result by 256 to get processed temperature in Kelvin
uint16_t temperature_in_K = temp;