KEA128 On Board Temperature

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

KEA128 On Board Temperature

Jump to solution
1,456 Views
MichaelBMiner
Contributor IV

I am trying to read the on board temperature of an S9KEAZ128M4 using AN3031. I am following the calculate Vdd procedure. 

Reading my bandgap voltage and calculating Vdd I get a value of 3.3V which is expected. Using this I calculate all required values. When reading in the temperarue AD22 and converting I get incorrect values. In regards to AN3031 I have two questions. 

  1. Are my values correct?
  2. When do I use the positive vs negative slope?

For 1. I have calculated a Vdd of 3.3V. Vtemp25 given by the datasheet is 1.396. Vbg is 1.16 typ. Following equations 3 through 7 I get the following values.

ADCRtemp25 = 1732

ADCRm = 451 for – Temp 25 < 40°C  < °C

ADCRm = 405 for 25°C < Temp 85 <  °C

An example reading from ADC22 is 1481. Putting this into the app note equation gives me a temperature of 80°C which is not correct.

 

For 2. What determines the slope to use? I get that it is when a Vtemp is above/below a certain point but which temp? The one from ADC22? If so how do I use that since it has yet to be converted to a temp.

 

 

Tags (2)
0 Kudos
1 Solution
1,427 Views
mjbcswitzerland
Specialist V

Hi

You know whether it is below or above 25°C from the ADC value comparison with the 25°C value. Therefore if ssDifference is negative the one slop can be used and if it is positive the other can be used. If it exactly matches the 25°C value either no slope or any slope can be used since it will result in no adjustment anyway.

Regards

Mark

 

View solution in original post

4 Replies
1,432 Views
MichaelBMiner
Contributor IV

I also have my ADC working. My new issue is with ADC FIFO

https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA-ADC-FIFO/m-p/1377751#M61944

0 Kudos
1,445 Views
mjbcswitzerland
Specialist V

Hi

This is the code in the uTasker project, which has been used with most Kinetis parts (available free at https://github.com/uTasker/uTasker-Kinetis including simulation of the Kinetis parts and ADC)

#define VTEMP_25_16BIT               ((VTEMP_25_MV * 0xffff) / ADC_REFERENCE_VOLTAGE)
#define VTEMP_25_12BIT               (VTEMP_25_16BIT >> 4)
#define VTEMP_25_10BIT               (VTEMP_25_16BIT >> 6)
#define TEMP_SENSOR_SLOPE_100_16BIT  ((TEMP_SENSOR_SLOPE_UV * 0xffff)/(10 * ADC_REFERENCE_VOLTAGE))
#define TEMP_SENSOR_SLOPE_100_12BIT  (TEMP_SENSOR_SLOPE_100_16BIT >> 4)
#define TEMP_SENSOR_SLOPE_100_10BIT  (TEMP_SENSOR_SLOPE_100_16BIT >> 6

// Convert the ADC reading to a temperature (using 12 bit resolution result)
//
signed short ssDifference = (sADC_value - VTEMP_25_12BIT); // convert references to 12 bit values
signed long slTemperature100 = (2550 - ((ssDifference * 10000) / TEMP_SENSOR_SLOPE_100_12BIT)); // the approximate temperature *100, rounded up/down
slTemperature100 /= 100;                         // the approximate temperature rounded up/down to 1°C
fnDebugDec(slTemperature100, DISPLAY_NEGATIVE);
fnDebugMsg(" degC\r\n");

 

Values used by KEA parts:
#define VTEMP_25_MV 1396 // typical internal temperature sensor reference voltage (in mV) (5.0V VDD/VREF and < 3MHz ADC clock speed)
#define TEMP_SENSOR_SLOPE_UV 3260 // typical internal temperature sensor slope uV/°C (5.0V VDD/VREF and < 3MHz ADC clock speed)

 

The expected value read by the ADC (in 16 bit mode) at 25°C is

(unsigned short)((VTEMP_25_MV * 0xffff) / ADC_REFERENCE_VOLTAGE); // 25°C

where the KEA typically uses 5V as reference, and so

#define ADC_REFERENCE_VOLTAGE 5000 // ADC uses 5.0V reference

Beware that the ADC resolution used must match with the ADC resolution calculated with (see above)
16 bit value is expected to be 18297 (0x4779)
12 bit value is 1143 (0x0477)
10 bit value is 285 (0x011d)

 

Therefore:
1. Which resolution is the ADC reading with?
2. What is your ADC reference voltage?
3. What is the ADC value read at 25°C (in dec or hex)? [1481 dec?]

Regards

Mark

0 Kudos
1,434 Views
MichaelBMiner
Contributor IV

Hello,

That repo and ADC solution only uses one slope. The data sheet for my part uses two slopes. One below 20 and one above 25. 

 

How do I know which to use? If I have not calculated the temperature yet, how do I know which slope to use to calculate the temperature?

0 Kudos
1,428 Views
mjbcswitzerland
Specialist V

Hi

You know whether it is below or above 25°C from the ADC value comparison with the 25°C value. Therefore if ssDifference is negative the one slop can be used and if it is positive the other can be used. If it exactly matches the 25°C value either no slope or any slope can be used since it will result in no adjustment anyway.

Regards

Mark