AnsweredAssumed Answered

Temperature Sensor reading 4095 on ADuC7024

Question asked by mabijaoude on Dec 12, 2012
Latest reply on Dec 14, 2012 by mabijaoude

The code that is used is directly from page 46.

We also use the AD Conversion for 6 other external signals that work as expected.  The reference voltage is set on startup.

 

In our AD() function the following code appears:

 

 

//Select On-Board Temperature Sensor

ADCCP = 0x10;









while (!ADCSTA){}


// wait for end of conversion
curTemperatureVal = (ADCDAT >> 16);

tmpA = 0x525-curTemperatureVal;

tmpA /= 1.3;

curTemperatureVal = floor(tmpA);

 

The problem was the value that was being stored in curTemperatureVal was -2137 not a valid temperature. Then I commented out the math and just displayed the curTemperatureVal after the ADCDAT register read.

The value was 4095.  Which means in a 12bit AD register -- 2^12 = 4095 and in binary : 1111 1111 1111

 

Clearly something is not right.  In the calibration section on page 46, there is reference to this value but I am not 100% sure if it explains why I am getting this issue.

 

I have also tried this modification for temperature sensor on different units and at different temperatures (20 degree C and 0 degree C).

 

The ADCOF is at the default 0x200

 

What I am not sure about is that the the ADCDAT register is used 6 different times before this code is called and the ADCDAT has dynamic data and not static 0xFFF

 

Below is an example of channel 5 being probed, One difference I noticed is that the there is two " while (!ADCSTA){} " is this required to get a correct result.

 

// Select channel 5

          ADCCP = 0x5;

          ADCCON = 0x0A4;                                                  // start single conversion

 

  while (!ADCSTA){}                              // wait for end of conversion

 

          mnADResult = (ADCDAT >> 16);

          ADCCON = 0x0A4;                                                  // start single conversion

 

while (!ADCSTA){}                              // wait for end of conversion

          giAmplifiedOut = giAmplifiedOut+(ADCDAT >> 16);

Outcomes