Hi,
I am using MK64FN1M0 and I am reading the temperature via ADC. Does anybody know what the conversion factor 'M' in Figure35-93 in the K64P144M120SF5RM manual is? Section 35.4.8 also mentioned use the Vtemp25 and 'M' values from the ADC Electrical table, where can I find this ADC Electicals table?
I tried the example in AN3031, the bandgap voltage always returns a different value, so Vdd changes everytime, which it shouldn't. Any idea how I can troubleshoot this?
Thanks.
Hi
Here is the temperature sensor code used in the uTasker project (sample in results.sADC_value[0] - 12 bit mode) and resulting temperature in °C in slTemperature100:
fnDebugHex(results.sADC_value[0], (WITH_SPACE | WITH_LEADIN | WITH_CR_LF | sizeof(results.sADC_value[0])));
#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)
if (ADC_TRIGGER == ucInputMessage[MSG_INTERRUPT_EVENT]) { // convert the ADC reading to a temperature
signed short ssDifference = (results.sADC_value[0] - 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");
}
where (for K64 and most such types)
#define VTEMP_25_MV 716 // typical internal temperature sensor reference voltage (in mV) (3.3V VDD/VREF and < 3MHz ADC clock speed)
#define TEMP_SENSOR_SLOPE_UV 1620 // typical internal temperature sensor slope uV/°C (3.3V VDD/VREF and < 3MHz ADC clock speed)
from the K64 data sheet Table 31.
Regards
Mark
[uTasker project developer for Kinetis and i.MX RT]