cancel
Showing results for 
Search instead for 
Did you mean: 

Reading and calibrating output from STM32WB die temperature sensor

MSing.1713
Associate II

Greetings,

This is surprising because it should be a simple task.  We've read from the die temperature sensor on other STM32 MCUs without issue.  In this case, we are using the STM32WB55MMG module.  We can read a calibrated value for the 3.3V VDDA input using the VREFINT sensor.  We measure a value corresponding to 3.28V which seems reasonable.  The calculation for the temperature sensor, though, isn't reasonable.

 

# temp: c 0x3ae1 (15073)  cadj 0x35ce (13774)  dc -194 (-19.4C)  vdda_mv 3283
#       cal1 v 0x40a0 (16544) dc 300  cal2 v 0x5680 (22144) dc 1300  ts_mv 3000
#       c/100c 350  a 0x3e8 (1000)  b 0xfffff52e (-2770)  c 0x15e0 (5600)  d 0x12c (300)

 

We are reading 12 bit samples left shifted into the MSB and averaging over 128 readings from the ADC.  The 'c' is the sampled value from the temperature sensor at room temperature, about 24C right now.  cadj is adjusted for the difference between the 3.0 value for the temperature sensor cal values and the 3.28V vdda.  dc is the computed temperature.  We're pretty sure -19C is wrong.  Cal1 and Cal2 are shown shifted into top of the 16 bit half-word to match the sensor sample.  dc refers to the 10ths of a degree C each cal constant represents, 30.0 and 130.0.  ts_mv is the 3.0V temperature sensor reference voltage.

The values a, b, c, and d are components of the conversion.  a is the difference in temperature 100.0C in 10ths of a degree between cal counts.  b is the difference of the measured count and cal1 and this is where the conversion seems wrong.  If x40a0 is cal at 30C, the sensor value x3ae1 is really far from cal1 it relative to the top end of the scale at 130C being x5680.  c is the difference between the cal2 and cal1 counts and d is the temperature at cal1 expressed in tenths of a degree.

We have checked the cal constants and they seem correct as read from memory.  The temperature sensor reading seems to be a bona fide sample from channel 17.  We've put the device into a refrigerator and the reading drops noticeably.  Disabling the temperature sensor changes the reading as well.  Adding delays and using the longest sample hold time doesn't change the result.

Is there something we are not understanding about the STM32WB die temperature sensor?

Cheers

2 REPLIES 2
MSing.1713
Associate II

I am not sure where I had gone wrong, but the code is now working correctly.  In the capture above, there was an error which was in the conversion from the TS count measurement at vdda and the count measurement in the Vcal which is 3.0V. 

MSing.1713
Associate II

FWIW, I think what was confusing was the fact that we're seeing 45C die temperatures at 21C ambient.   It's certainly fine, but it is substantially warmer than the other MCUs we've used.