Quantcast
Channel: MSP low-power microcontroller forum - Recent Threads
Viewing all articles
Browse latest Browse all 21942

CCS: I could not read temperature value cnsistently.

$
0
0

Tool/software: Code Composer Studio

Hi,

I am trying to get temperature value but for sometimes it use to work fine but afterwards data is irrelevant.First i read a voltage reading using ADC and then temperature reading.I.e

1. Voltage reading using a code  below.

REF_A_disableReferenceVoltageOutput();
REF_A_enableReferenceVoltage();
REF_A_setReferenceVoltage(REF_A_VREF2_5V);
ADC14_setResolution(ADC_14BIT );

/* Initializing ADC (SMCLK) */
ADC14_enableModule();
ADC14_initModule(ADC_CLOCKSOURCE_SMCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_1,0);

/* Configuring ADC Memory */
ADC14_enableReferenceBurst();
ADC14_configureSingleSampleMode(ADC_MEM0, true);

/* Configuring Sample Timer */
ADC14_enableSampleTimer(ADC_AUTOMATIC_ITERATION);

/* Enabling interrupts */
ADC14_enableInterrupt(ADC_INT0);


ADC14_configureConversionMemory(ADC_MEM0,ADC_VREFPOS_INTBUF_VREFNEG_VSS,
ADC_INPUT_A1, false);
/* Enabling/Toggling Conversion */
ADC14_enableConversion();
ADC14_toggleConversionTrigger();
//i=0;
//while(i<=12)
{
uint64_t status = ADC14_getEnabledInterruptStatus();
ADC14_clearInterruptFlag(status);

if (ADC_INT0 & status)
{
//vltg[i] = ADC14_getResult(ADC_MEM0);
vltg =(((ADC14_getResult(ADC_MEM0) *2.5f) / 16384)*2)*100;
//i++;
}
}
ADC14_disableConversion();

And then i  use read temperature,code shown as below

 

volatile float temp;
uint16_t ltempC =0;
uint32_t cal30, cal85;
/* Setting reference voltage to 2.5 and enabling temperature sensor */
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_MCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_1,
ADC_TEMPSENSEMAP);
/* Configuring ADC Memory (ADC_MEM0 A22 (Temperature Sensor) in repeat
* mode).
*/
ADC14_configureSingleSampleMode(ADC_MEM0, true);
ADC14_configureConversionMemory(ADC_MEM0, 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_INT0);
/* Triggering the start of the sample */
ADC14_enableConversion();
ADC14_toggleConversionTrigger();
/* Going to sleep */
//i=0;
//while (i<=21)
{
uint64_t status = ADC14_getEnabledInterruptStatus();
ADC14_clearInterruptFlag(status);

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

temp = (float) (((int32_t) ADC14_getResult(ADC_MEM0) - cal30) * (85 - 30))
/ (cal85 - cal30) + 30.0f;
ltempC = temp;
//tempF = tempC * 9.0f / 5.0f + 32.0f;
}
}
ADC14_disableConversion();

A typical temperature sensor transfer function is shown in Figure 20-10. The transfer function shown here
is only an example. Calibration is required to determine the corresponding voltages for the specific device.
When using the temperature sensor, "the sample period must be greater than 5 µs". The temperature
sensor offset error can be large and must be calibrated for most applications. Temperature calibration
values are available for use in the TLV descriptors (see the device-specific data sheet for locations).

The above text is  in the  MSP432P4xx Family Technical Reference Manual with a page no 662  the doubt i  have is what is the meaning of "the sample period must be greater than 5 µs".

Give me some solution to get consistent temerature value.

Thanks & regards

praveen kumar G.


Viewing all articles
Browse latest Browse all 21942

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>