Hi Team,
I want to measure the core temperature for the MC9s12ZCM,
I have enabled Temperature sensor and configured voltage level generated by the temperature sensor is driven to a special channel input of the ADC Converter.
/* Temperature sensor/Bandgap voltage enable bit is enabled */ |
CPMUHTCTL_HTE = 1;
/*! Voltage Access Select Bit is toggled to read : | |
* 1) VSEL = 0, internal temp proportional to VHT | |
* 2) VSEL = 1, Bandgap refernce voltage (VBG) | |
*/ |
CPMUHTCTL_VSEL = 0;
Also configured adc1 channel to read the result of temperature sensor with configuration
Temp Sensor, Internal_0, 4 clock cycles sample time
written {0x00,0xC8,0x00,0x00}, at address 0x00002040
With this configuration, I am getting the raw count for temperature sensor as around 1095:
Considering the ADC reference voltage as 5V (VADD =5V)
Voltage with count 1095 = 1.33 V (with 12 bit adc)
So, for calculating the physical value of temperature I am referring following formula :
VHT(temp) = VHT(150) - (150 - temp) * dVHT
where, as per electrical specification
VHT(150) = 2.33 V
dVHT = 5.05 mv/degree Cel(typical)
So for temperature range 150 to -40 degree VHT ranges from 2.33 to 1.37 V
But in my case for the adc count are read as 1095, so VHT measured is 1.33V which is not in acceptable range f 1.37V to 2.33 so temperature value is bellow -40 degree.
And I think this is not the valid scenario, Core temperature must not be too low.Please help me to resolve this issue. Let me know if I am missing any configuration
Regards,
Amey
Hi Amey,
I suppose that you mean S12ZVMC128 device. Correct?
Small clarification as first:
S12ZVM has three independent temperature sensors. One is part of the voltage regulator (internal_1 - VREG temperature sensor or bandgap (VBG)) and two are parts of ADC modules (Internal_0 - ADC0 temperature sensor and ADC1 temperature sensor).
So, you don’t need CPMUHTCTL for measuring Internal_0 channel.
I measured ADC0 and VREG temperature sensors on my MCU and results are 1070 for ADC0_TEMP (Internal_0) and 1353 for VREG_TEMP (Internal_1).
1353 refers to approximately 1.65V and this fits 24°C in our office plus some heating from MCU.
In fact, the temperature sensor based on PN junction is a quite variable source of a signal.
The offset is typically specific per device and slope may also slightly vary between different devices.
From the physical point of view, only the linearity of this sensor is fixed – rather say that nonlinearity is negligible.
So, typically we need some calibration. See more details in our application note AN3031 Temperature Sensor for the HCS08 Microcontroller Family
http://www.nxp.com/files/microcontrollers/doc/app_note/AN3031.pdf
and AN3624 S12X Temperature Sensor
http://www.nxp.com/files/microcontrollers/doc/app_note/AN3624.pdf
It seems that VREG temperature sensor is already calibrated – therefore, you already have “VHT(temp) = VHT(150) - (150 - temp) * dVHT” formula and typical VHT value in the reference manual.
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Redek,
Yeah, its S12ZVMC128 device.
Thanks for your comment.
I have two doubts here - 1. I don't understood, How you have calculated at 1.65V it is 24°C ? , as per my calculation it is coming as 14°C.
2. At ADC0 you have mentioned your results as 1070 counts. Then here, how we can calculate the temperature?
what will be formula for same in this case? or any manual calibration is require in that case.
Regards,
Amey
Hi Amey,
You are right, it is my fault. I used wrong sign.
24°C was my estimation (just personal feeling) of ambient temperature in office.
When I recalculated it again, it gives 15.67°C to me.
Since we use the typical value of VHT(150), the typical value of dVHT and assumed 5V VDDA voltage for calculation, it is still pretty good result.
If you will need higher accuracy, please use VDDA voltage compensation, and one or rather at least two point calibration of VHT offset and dVHT.
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Anybody, please share your inputs, so that it will help me to resolve the issue asap.
regards,
Amey
i recognized that the internal temperature offset and the temperature slope is not corresponding with the datasheet.
I meassured several devices and i always got an offset of 1096-1100 Digits @ about 25C°. The datasheed seems to be wrong.