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