Actually I am working with a STM32L433CBY controller. When using the internal temperature sensor I got some inconsistencies and strange readings. Maybe someone can clarify the issues.
1. Reference temperature TS_CAL2
The Datasheet(STM32L433) explains on page 40 both calibration points. TS_CAL2 is defined to be 130°C.
The Reference manual (RM0394) introduces on page 423 (center) the formula for using the calibration points. Here TS_CAL2 is defined to be 110°C.
Any Idea which value is the correct one?
I get different values when enabling 16x oversampling for the ADC. At room temperature (~25°C, VCC=3.3V) I get an ADC reading (after a division by 16) of 0x2FE. When I deactivate oversampling I get 0x343 for the same temperature on the same hardware. Is there any limitation regarding oversampling of the internal temperature sensor? Did I miss something in the errata sheet? (PS: Tried it also on different controllers, same result.)
3. Unrealistic readings of the temperature sensor
When I fill in the values from (2) into the formula, I get quite strange results. First I converted the readings into millivolts to compare them to page 155 of the datasheet. The datasheet states that I should get about 0.76V at 30°C.
0x02FE ==> 620mV (much too low, even for 25°C)
0x0343 ==> 670mV (better but still to low!)
When I use these values for the formula (RM0394, pp423) with the calibration values
TS_CAL1 = 1031
TS_CAL2 = 1371
I first have to normalize the readings to 3.0V (since the calibration was done at that voltage).
TS_DATA = 0x343(=835) * 3,3V / 3,0V ==> 0x396 (=918)
T = (110°C-30°C) / (1371 - 1031) * (TS_DATA - 1031) + 30°C
= 80°C / 340 * (TS_DATA - 1031) + 30°C
= 0,235°C * (TS_DATA - 1031) + 30°C
= 0,235°C * -113 + 30°C
= 3,44°C (*brrr, coooold*)
When replacing TS_CAL2=110°C with TS_CAL2=130°C I get
T = 0,294°C * (TS_DATA - 1031) + 30°C
T = 0,294°C * -113 + 30°C
T = -3,2°C (*coooolder*)
Any ideas what's going wrong?