This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS: ADC READING FOR TEMPERATURE.



Tool/software: Code Composer Studio

Hi,

The below code is to find temperature.Actually i can read temperature exactly for some times and later for same code data is not correct.So please suggest for consistnt answer or data

/* DriverLib Includes */
#include "LibG2_main.h"
volatile float tempC;
volatile float tempF;
int64_t status;
//uint32_t cal30, cal85;
//#define cal30 *((unsigned int *)0x002010DC) // Temperature Sensor Calibration-30 C
// See device datasheet for TLV table memory mapping
//#define cal85 *((unsigned int *)0x002010E0) // Temperature Sensor Calibration
volatile int32_t temp;
int32_t cal30, cal85;
int main(void)
{
int q;
/* Halting WDT */
WDT_A_holdTimer();

/* Enabling the FPU with stacking enabled (for use within ISR) */
//FPU_enableModule();
//FPU_enableLazyStacking();

REF_A_setReferenceVoltage(REF_A_VREF2_5V);
REF_A_enableReferenceVoltage();
REF_A_enableTempSensor();


/* Initializing ADC (MCLK/1/1) with temperature sensor routed */
ADC14_enableModule();
ADC14_initModule(ADC_CLOCKSOURCE_SMCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_1,
ADC_TEMPSENSEMAP);

/* Configuring ADC Memory (ADC_MEM0 A22 (Temperature Sensor) in repeat
* mode).
*/
ADC14_configureSingleSampleMode(ADC_MEM1, true);
ADC14_configureConversionMemory(ADC_MEM1, ADC_VREFPOS_INTBUF_VREFNEG_VSS ,
ADC_INPUT_A22, false);

/* Configuring the sample/hold time for TBD */
ADC14_setSampleHoldTime(ADC_PULSE_WIDTH_192,ADC_PULSE_WIDTH_192);

/* Enabling sample timer in auto iteration mode and interrupts*/
ADC14_enableSampleTimer(ADC_AUTOMATIC_ITERATION);
ADC14_enableInterrupt(ADC_INT1);

/* Setting reference voltage to 2.5 and enabling temperature sensor */

/* Enabling Interrupts */
//Interrupt_enableInterrupt(INT_ADC14);
//Interrupt_enableMaster();

/* Triggering the start of the sample */
ADC14_enableConversion();
ADC14_toggleConversionTrigger();

/* Going to sleep */
while (1)
{
status = ADC14_getEnabledInterruptStatus();
ADC14_clearInterruptFlag(status);

if(status & ADC_INT1)
{
cal30 = SysCtl_getTempCalibrationConstant(SYSCTL_2_5V_REF,
SYSCTL_30_DEGREES_C);
cal85 = SysCtl_getTempCalibrationConstant(SYSCTL_2_5V_REF,
SYSCTL_85_DEGREES_C);

tempC = (float) (((int32_t) ADC14_getResult(ADC_MEM1) - cal30) * (85 - 30))
/ (cal85 - cal30) + 30.0f;

tempF = tempC * 9.0f / 5.0f + 32.0f;
}
}
}

**Attention** This is a public forum