UG-1262
Rev. B | Page 62 of 312
INTERNAL TEMPERATURE SENSOR CHANNELS
The
analog die contains two internal temperature sensor channels.
Temperature Sensor 0
The temperature sensor outputs a voltage proportional to die temperature. This voltage is linear relative to temperature. This internal
channel is measured via the ADC by selecting the temperature sensor channels as the positive and negative inputs from the mux. The die
temperature is calculated by the following:
(
TEMPSENSDAT0
/(
PGA Gain
×
K
))
−
273.15
(2)
where
K
= 8.13.
For improved accuracy, configure the temperature sensor in chop mode via TEMPCON0, Bits[3:1]. If chopping is selected, the user must
ensure an even number of ADC conversions take place on the temperature sensor channel and that these results are averaged.
Dedicated calibration registers for the temperature sensor channel are also available. When the ADC selects the temperature sensor as
the positive input, the calibration values in the ADCOFFSETTEMPSENS0 and ADCGAINTEMPSENS0 registers are automatically used.
To enable the internal temperature sensor, set AFECON, Bit 12 = 1. Select ADC input channels as follows:
ADCCON, Bits[12:8] = 01011 to select the ADC negative input channel.
ADCCON, Bits[5:0] = 001011 to select the positive input channel.
To start an ADC conversion of the temperature sensor channel, set AFECON, Bit 13 and AFECON, Bit 8 to 1. For optimal temperature
sensor results, enable chop mode of the temperature sensor with the 6.25 kHz chopping frequency. Then, average an even number of
ADC temperature sensor results to eliminate any inaccuracies due to the chopping clock.
The following code snippets demonstrate how to set up and use the Temperature Sensor 0:
void InitAfeADC(void)
{
AfeAdcPwrUp(BITM_AFE_AFECON_ADCEN); // power up the ADC
AfeAdcCfg(GNPGA_1_5, 0); // Configure ADC to measure Temp. output
AfeAdcChan(MUXSELP_TEMP,MUXSELN_TEMPN); // Select Temp sensor inputs to the ADC
AfeAdcIntCfg(
BITM_AFE_ADCINTIEN_ADCRDYIEN| // Select ADCReady and Temp sensor channels as
interrupt sources
BITM_AFE_ADCINTIEN_TEMPRDYIEN);
pADI_AFE->AFECON |=
BITM_AFE_AFECON_TEMPSENSEN0; // Enable the ADC temp sensor channel
pADI_AFE-> TEMPCON0 = 0x2; // Turn on Temp sensor chopping with
6.25kHz chop clock
pADI_AFE->REPEATADCCNV = 0x11;
NVIC_EnableIRQ(AFE_ADC_IRQn); // Enable AFE_ADC interrupt source in NVIC
}
// ADC Interrupt handler
void AfeAdc_Int_Handler()
{
uiIntSta = AfeAdcIntSta();
if (uiIntSta & BITM_AFE_ADCINTSTA_ADCRDY)
{
}
if (uiIntSta & BITM_AFE_ADCINTSTA_TEMPRDY) // Check for Temp sensor flag
{
TEMP_RESULT= AfeAdcRd(TEMPSENSOR);
pADI_AFE->ADCINTSTA |=