AnsweredAssumed Answered

K21 temperature sensor transfer function

Question asked by Phuc Le Dinh on Jul 22, 2015
Latest reply on Jul 24, 2015 by Phuc Le Dinh

Hi,

 

I'm working on a K21 target and want to read the internal temperature sensor. I've set up the PE for the ADC and am able to get ADC readings out. However converting from the ADC readings to the actual Temperature reading is proven to be a little bit tricky. I've consulted AN3031 an various threads on here but haven't got a solution yet.

 

My problem is that the temperature converted from the ADCR is not correct even though it increase and decrease in the right direction, my guess is that my implementation of the transfer function is not correct. Below is my transfer function implementation:

 

uint32_t GetTemperature(uint32_t ADCR_Temp)
{
  uint32_t Vtemp_mV = ADCR_Temp * 1800 / ( (1 << AdcLdd1_ADC_RESOLUTION) - 1 ) ; //Convert the ADC reading into voltage
  uint32_t Temp1;
  uint32_t Temp2;
  Temp2 = ( Vtemp_mV - 716 ) * 617; // 1 / 0.00162 = 617
  Temp1 = 25000 - Temp2;
  return (uint32_t) (Temp1);
}


}

Here is the printf of the program:

Vtemp ADCR: 1711,Temperature: 2.788 ▒C

Vtemp ADCR: 1711,Temperature: 2.788 ▒C

Vtemp ADCR: 1711,Temperature: 2.788 ▒C

Vtemp ADCR: 1711,Temperature: 2.788 ▒C

Vtemp ADCR: 1711,Temperature: 2.788 ▒C

Vtemp ADCR: 1711,Temperature: 2.788 ▒C

Vtemp ADCR: 1711,Temperature: 2.788 ▒C

Vtemp ADCR: 1710,Temperature: 3.405 ▒C

And I'm pretty sure I'm sitting in a room at about 20 degrees C, unless there is something else going on (!?).

And I'm using 1.8V for VREFH and Ground for VREFL. ADC resolution 12 bits

 

Any help is much appreciated.

 

Many thanks,

Outcomes