Normal 0 21 false false false MicrosoftInternetExplorer4
Hello everyone I’m new to microcontroller programming and the CC1110F32.
I try to get the value of the internal temperature sensor of the CC1110 via the ADC, Ive done everything like it was said in the Datasheet of the CC1110F32 and the Design Note DN102 but I got a problem when I want the return value of the function getTemp().
Normal 0 21 false false false MicrosoftInternetExplorer4
Here is my source code:
#define SAMPLE_TEMP_SENSOR(v) \
do { \
ADCCON2 = 0x3E; \
ADCCON1 = 0x73; \
//The ADC Registers are set like in the Design Note DN102
while(!(ADCCON1 & 0x80)); \
v = ADCL; \
v |= (((unsigned int)ADCH) << 8); \
} while(0)
#define CONST 0.61065
// typical output voltage [mV] at 0°C
#define OFFSET_DATASHEET 755
// offset measuered at 25°C due to 1-point calibration
#define OFFSET_MEASURED_AT_25_DEGREES_CELCIUS 16
// calculate overall offset
#define OFFSET (OFFSET_DATASHEET + OFFSET_MEASURED_AT_25_DEGREES_CELCIUS)
// temperatur coeffizient
#define TEMP_COEFF 2.47
//coefficients like in Design Note DN102 with slightly diffrent values
float getTemp(void)
{
unsigned int adcValue;
float outputVoltage;
SAMPLE_TEMP_SENSOR(adcValue);
// Note that the conversion result always resides in MSB section of ADCH:ADCL
adcValue >>= 4; // Shift 4 due to 12 bits resolution
outputVoltage = adcValue * CONST;
return ((outputVoltage - OFFSET) / TEMP_COEFF);
}
I wrote in my main function:
float testtemperature;
testtemperature=getTemp();
But I get a warning that says:
Warning[Pe550]: variable "testtemperature" was set but never used
I don’t understand what is wrong with my code or what I have forgotten. When I'm right the function “getTemp” should have a return value of the type float like testtemperature.
Thanks in advance