Hi Tikai,
When I dig into more I found some problem in my board design. That input voltage was reaching at more than the reference voltage.
But This is true that output will be in 2s complement if & only if result is -ve as every processing system employs the same. This can be observed in one of the example design provide by the TI only, in Sensor Demo App. For reference I am pasting the readTemp() function where we will find any code which performs 2S complement on the result as it is necessary if result is in 2S complement irrespective of the sign.
Although if we choose single ended conversion , it has been take into consideration that input may go to -ve w.r.t ground (in my case due to noise it went to very very small -ve). So I got a 2S complemnt from of output in case zero input voltage which if read as unsigned decimal, will lead to a very hign value. This was the case happened to me in case of zero input voltage.
********************************************************************************************************************************************************************************************************* READ TEMPERATURE FUNCTION FOR CC2530/2531 Provided By TI ******************************************************************************************** ***********************************************************************************************************************************************************************************************
static int8 readTemp(void)
{
static uint16 voltageAtTemp22;
static uint8 bCalibrate=TRUE; // Calibrate the first time the temp sensor is read
uint16 value;
int8 temp;
#if defined (HAL_MCU_CC2530)
ATEST = 0x01;
TR0 |= 0x01;
/* Clear ADC interrupt flag */
ADCIF = 0;
ADCCON3 = (HAL_ADC_REF_125V | HAL_ADC_DEC_512 | HAL_ADC_CHN_TEMP);
/* Wait for the conversion to finish */
while ( !ADCIF );
/* Get the result */
value = ADCL;
value |= ((uint16) ADCH) << 8;
// Use the 12 MSB of adcValue
value >>= 4;
/*
* These parameters are typical values and need to be calibrated
* See the datasheet for the appropriate chip for more details
* also, the math below may not be very accurate
*/
/* Assume ADC = 1480 at 25C and ADC = 4/C */
#define VOLTAGE_AT_TEMP_25 1480
#define TEMP_COEFFICIENT 4
// Calibrate for 22C the first time the temp sensor is read.
// This will assume that the demo is started up in temperature of 22C
if(bCalibrate) {
voltageAtTemp22=value;
bCalibrate=FALSE;
}
temp = 22 + ( (value - voltageAtTemp22) / TEMP_COEFFICIENT );
// Set 0C as minimum temperature, and 100C as max
if( temp >= 100)
{
return 100;
}
else if (temp <= 0) {
return 0;
}
else {
return temp;
}
// Only CC2530 is supported
#else
return 0;
#endif
}