Hello, guys! I just came across a strange problem and want to get some help here.
I try to read the temperature from the temperature sensor. The variable sensorSample is the value from the ADC. In the function GetTemperatureC,
I want to convert the voltage value sensorSample to the exact temperature value.
Here is the code:
float32 tempSensor_tempSlope;
float32 tempSensor_tempOffset;
float32 tempSensor_scaleFactor;
float32 temperature;
tempSensor_tempSlope = 1.0/6.25;
tempSensor_tempOffset = 424;
tempSensor_scaleFactor=3;
float32 GetTemperatureC(float32 sensorSample)
{
sensorSample = (float32)((tempSensor_scaleFactor/2.5)*(sensorSample));
temperature=((float32)(sensorSample*1000) - tempSensor_tempOffset)*(float32)tempSensor_tempSlope;
return temperature;
}
The value of variable 'sensorSample' is around 0.75, according to the above formula, the value of variable 'temperature' should be around 52.
However, in the debug tool, I add 'temperature' to watch expression, it is around 78. Then I add the right side of the equation to the watch expression, the
right side is around 52-not equal to the left side.
Why the left side of the equation is not equal to the value of the right side of the equation?
environment : Windows 7 64-bit,SP1; CCS version number 6.1.1.00022; board TMS320F2837xD dual-core delfino;
debug probe:xds100v2