An on-chip temperature sensor is available. To do a temperature
measurement, follow these steps:
Configure the voltage
reference to internal 2.048V 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 10-bit Single-Ended
conversion.
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:
It is recommended to follow these steps in the application code
when using the compensation values from the Signature
Row:
#defineSCALING_FACTOR1024// 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 = ADC0.RESULT; // ADC0 conversion result
uint32_t temp = sigrow_offset - adc_reading;
temp *= sigrow_slope; // Result will overflow 16-bit variable
temp += SCALING_FACTOR / 2; // Ensure 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;
If another reference (VADCREF) than 2.048V is required, the
offset and slope values need to be adjusted according to the following
equations: