There is an internal temperature sensor embedded into the TI ARM Tiva chip. This gives us the temperature inside the ARM chip itself. The temperature sensor does not have any separate enable control, because it also contains the band-gap reference and must always be enabled. The reference is also supplied to other analog modules, not just the ADC. In addition, the temperature sensor has a second power-down input in the 3.3V domain which provides control by the Hibernation module.
The internal temperature sensor converts a temperature measurement into a voltage. This voltage value, VTSENS, is given by the following equation (where TEMP is the temperature in °C):
VTSENS = 2.7 - ((TEMP + 55)/75)
The temperature sensor reading can be sampled in a sample sequencer by setting the TSn bit in the ADCSSCTLn register. The temperature reading from the temperature sensor can also be given as a function of the ADC value. The following formula calculates temperature (TEMP in °C) based on the ADC reading that is an ADC_output given as an unsigned decimal number from 0 to 4095 and the maximum ADC voltage range (Vref(+) Vref(–)):
Temp = 147.5 – ((75 × Vref(+) – Vref(–)) × ADC_output)) / 4096
Since the Vref = 3.3 V in TI Tiva Launchpad, we have:
Temp = 147.5 – ((75 × 3.3V) × ADC_output) / 4096 Temp = 147.5 – (247.5 × ADC_output) / 4096
Example: Find the temperature inside the ARM chip for the TI Tiva Launchpad if the reading of ADC output is = 0x7D0.
Solution: The 0x7D0 is 2000 in decimal. Now, we have
Temp = 147.5 – (247.5x2000) / 4096 = 147.5 – 120.85 = 26.6 Celsius
Source Code
-
/* Convert on-chip temperature
-
*
-
* Runs on TM4C123 LaunchPad
-
*
-
* This program converts the on-chip temperature sensor output using
-
* sample sequencer 3 and timer trigger at 1 Hz.
-
*
-
*/
-
#include <stdint.h>
-
#include "inc/tm4c123gh6pm.h"
-
int main(void)
-
{
-
volatile int temperature;
-
/* enable clocks */
-
SYSCTL_RCGCADC_R |= 1; /* enable clock to ADC0 */
-
SYSCTL_RCGCWTIMER_R |= 1; /* enable clock to WTimer Block 0 */
-
/* initialize ADC0 */
-
ADC0_ACTSS_R &= ~8; /* disable SS3 during configuration */
-
ADC0_EMUX_R &= ~0xF000;
-
ADC0_EMUX_R |= 0x5000; /* timer trigger conversion seq 0 */
-
ADC0_SSMUX3_R = 0; /* get input from channel 0 */
-
ADC0_SSCTL3_R |= 0x0E; /* take chip temperature, set flag at 1st sample */
-
ADC0_ACTSS_R |= 8; /* enable ADC0 sequencer 3 */
-
/* initialize wtimer 0 to trigger ADC at 1 sample/sec */
-
WTIMER0_CTL_R = 0; /* disable WTimer before initialization */
-
WTIMER0_CFG_R = 0x04; /* 32-bit option */
-
WTIMER0_TAMR_R = 0x02; /* periodic mode and down-counter */
-
WTIMER0_TAILR_R = 16000000; /* WTimer A interval load value reg (1 s) */
-
WTIMER0_CTL_R |= 0x20; /* timer triggers ADC */
-
WTIMER0_CTL_R |= 0x01; /* enable WTimer A after initialization */
-
while(1) {
-
while((ADC0_RIS_R & 8) == 0)
-
; /* wait for conversion complete */
-
temperature = 147 - (247 * ADC0_SSFIFO3_R) / 4096;
-
ADC0_ISC_R = 8; /* clear completion flag */
-
}
-
}
Recent Comments