2022-01-17 06:51 AM
I am trying to measure/calculate the internal temperature of an STM32G0B1VE design.
The algorithm used is taken from the reference manual RM0444 Rev 5 pages 376-378:
Temperature in degreesC = ((TS_CAL2_TEMP-TS_CAL1_TEMP) / (TS_CAL2-TS_CAL1)) * (TS_DATA-TS_CAL1) + TS_CAL1_TEMP
The calibration values are taken from the data sheet, see stm32g0b1ve.pdf (DS13560 Rev 1) page 25.
TS_CAL1_TEMP = 30 (defined in data sheet)
TS_CAL2_TEMP = 130 (defined i data sheet)
TS_CAL1 = 0x3FF (speficic to my controller, retrieved from 0x1FFF75A8)
TS_CAL2 = 0x560 (specific to my controller, retrieved from 0x1FFF75CA)
measured = 0x39F
If I run the calculation, I get 3°C. Is there something I did wrong?
Attached is a minimal STM32CubeMX/STM32CubeIDE example
Solved! Go to Solution.
2022-01-17 07:12 AM
2022-01-17 06:54 AM
Is your VDD the same as in the cal values? I believe they’re taken at 3.0V.
what raw adc value do you get?
2022-01-17 06:55 AM
You mean raw value for VRefInt?
2022-01-17 07:00 AM
No, for the temperature sensor. But if you have it, yes that one too.
2022-01-17 07:00 AM
VRefInt raw 0x5d5, VBat raw 0x55f
2022-01-17 07:03 AM
Raw value for temperature was 0x39F (my calculation is a bit off -> ~0°C)
2022-01-17 07:08 AM
2022-01-17 07:11 AM
Yes you are correct. VDD is 3.3V. I guess I have to take this into account. But where/how exactly?
2022-01-17 07:12 AM
2022-01-17 07:17 AM
This sounds reasonable. By using the updated value I get ~26°C