An on-chip temperature sensor is available. To do a temperature measurement, follow these
steps:
Configure the voltage reference
to internal 1.024V by writing to the Reference Selection (REFSEL) bit field the
ADCn.CTRLC register.
Select the temperature sensor as
input in the Positive Input Multiplexer (ADCn.MUXPOS) register.
Configure the ADC Sample Duration
by writing a value ≥ to the Sample Duration (SAMPDUR) bit field in
the Control E (ADCn.CTRLE) register.
Acquire the temperature sensor
output voltage by running a 12-bit Single-Ended conversion.
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 the Signature Row:
SIGROW.TEMPSENSE0 is a gain/slope
correction
SIGROW.TEMPSENSE1 is an offset
correction
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. Refer to the Electrical Characteristics section
for further details.
The following equation is used to calculate the temperature (in Kelvin):
It is recommended to follow these steps in the user code when using
the compensation values from the Signature
Row:
#defineSCALING_FACTOR4096// Enables integer in the signature row
int16_t sigrow_offset = (int16_t) SIGROW.TEMPSENSE1; // Read signed offset from signature row
int16_t sigrow_slope = (int16_t) SIGROW.TEMPSENSE0; // Read signed slope from signature row
uint16_t adc_reading = ADC0.RESULT; // ADC conversion result
int32_t temp = ((int32_t) adc_reading) + sigrow_offset;
temp *= sigrow_slope; // Result can overflow 16-bit variable
temp += SCALING_FACTOR / 2; // Ensures correct rounding on division below
temp /= SCALING_FACTOR; // Round to the nearest integer in Kelvin
uint16_t temperature_in_K = (uint_16t) temp;
int16_t temperature_in_C = temp - 273;
The online versions of the documents are provided as a courtesy. Verify all content and data in the device’s PDF documentation found on the device product page.