Hi ,
TEMP = 147.5 - ((75 * (VREFP - VREFN) × ADCCODE) / 4096) , this is the formula that is taken as a reference from the data sheet to calculate the temperature .
We have some challenge in computing the negative temperature values.
below is the code snippet:
unsigned char
get_temp(void)
{
unsigned int count = 0;
unsigned int temp_X_10 = 0;
unsigned char temp;
count = adc_count_volt_seq1[2]; // the ADC _CODE read from the internal ADC of MCU .
temp_X_10 = (1475 - ((75 * 30 * count)/4096)); //VREFP-VREFN =3 V
temp = temp_X_10/10;
return temp;
}
here the temp is defined as unsigned char and since there is no provision to send the values to cpu in the form signed char it is declared to be unsigned char.
when the temp_X_10 value goes negative , the final temp value that is computed results to be 153 and keeps on reducing with increase in the negative value of temp_X_10 .
So when this 153 is send to CPU how can it be decoded to the actual negative temperature value ?
it would be very thankful if there is any solution .Thanks in Advance .
Regards,
Rohith.