cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H723 / 733 / 735 analog temperature sensor vs. ADC Vref

LCE
Principal

Heyho,

got my custom board running, only (minor) problem until now:

internal analog temperature sensor (ADC3) value seems to be off, showing something like ~60°C,
while an external sensor shows about 30°C.
"Finger test" confirms rather the 30°C.

I have the exactly same code running on H723 Nucleo and H735 Disco, the values I get from these make sense.

ADC3 is working, I'm measuring about 7 supply voltages on the board and the internal Vref, all these values are close to perfect.

The only difference:
VREFP pin is connected to an external voltage reference with 3.0 V, VDDA is 3.3 V, compared to the Vref 3.3V on the ST boards.

So how does this affect the temperature sensor?
Even with a factor of (3.3 / 3.0) the measured temperature is still far off.

Here's how temperature is calculated, input is an averaged float from ADC buffer (I checked that this value is close to a single raw ADC value):

/* convert averaged float ADC value to temperature */
float ConvAdc2Temp(float flAdcTemp)
{
	/* calculate temperature, see reference manual */
	float flTempVal = flAdcTemp;

	flTempVal -= (float)((int32_t)*TEMPSENSOR_CAL1_ADDR);
	flTempVal *= (float)TEMPI_CAL_MULT;
	flTempVal += (float)((int32_t)TEMPSENSOR_CAL1_TEMP);

	return flTempVal;
}

Here's the output, including the MCU's internal calibration values, which are very close to those on the ST boards:

MCU internal temperature sensor:
ADC3 TmpSns: 866 / 0x0362
flTempMCU: 62.2 °C

TEMPSENSOR_CAL1_TEMP  = 30
TEMPSENSOR_CAL2_TEMP  = 110
*TEMPSENSOR_CAL1_ADDR = 768
*TEMPSENSOR_CAL2_ADDR = 1022
TEMPI_CAL_MULT = 0.31496

TMP101 external temperature sensor:
flTempSns: 34.0000 °C

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

> How does the external reference voltage of 3.0 V affect the temperature sensor?

In the same way as for any other ADC measurement. What you want to measure is the temperature sensor's voltage; for that you take ADC reading and then convert it into voltage by using the reference voltage.

Also, if you want to use the constants stored in system memory, for 'H733 they have been taken for VREF=3.3V (the DS partially incorrectly says VDDA=3.3V), so you have to take that into consideration when using them in calculation, too.

waclawekjan_0-1719484422949.png

JW

View solution in original post

9 REPLIES 9
STOne-32
ST Employee

Dear @LCE ,

 

Can you let us know if these behavior is only on one device ( which Package used ) ? Or many boards / devices having similar behavior.

 

Try also to use two points reference at 30 and 130 degree  and compute the coefficient of the ramp in that device ( without using the average slope of 2mV/C) as below :

IMG_8632.jpeg

Hope it helps ,

Cheers,

STOne-32 

LCE
Principal

Hello @STOne-32 ,

thanks for your reply.

- package: LQFP-144 (STM32H733ZGT6), same package as Nucleo H723

- same problem on multiple boards

- with each temperature calculation, I think I use the 2-point calibration values, as seen above, with:

 

 

#define TEMPI_CAL_MULT (float)( (float)(TEMPSENSOR_CAL2_TEMP - TEMPSENSOR_CAL1_TEMP) \
/ (float)((int32_t)*TEMPSENSOR_CAL2_ADDR - (int32_t)*TEMPSENSOR_CAL1_ADDR) )

 

 

The most common pitfall is failure to calibrate the ADC before use, as the RM requires. The other is failure to observe the required settling and sampling times.

A list of possible problems with temperature sensor here.

If you've followed that and no improvement, post concrete numbers (ADC settings/registers content, related frequencies, readouts, values of calibration constants).

JW

LCE
Principal
12-bit ADC, html auto update 1/s
VINV		11.52 V / 1437
VINI		0.279 A / 394
V3V3		3.303 V / 2226
V5VA		4.68 V / 2016
VA12V		12.80 V / 3493
VA2V7		2.93 V / 2639
VICP		23.91 V / 2997
UCC1		0.005 V / 0
UCC2		0.004 V / 10
VRefi 1.2V	1.214 V / 1658
MCU Temp	60.74 ℃ / 860 / 860
TMP101		34.00 ℃

Hello @waclawek.jan ,

thanks for your input!

ADC3 calibration is performed.

Above you can see the results of all 11 ADC3 channels, which are pretty good, including the internal voltage reference which I always use to check the ADC setup in general.

Only the internal temperature sensor ("MCU Temp") seems to be off.

The external temperature sensor (TI's TMP101, via I2C) feels actually a little warmer than the STM32 (the TMP101 is placed closer to the "hottest" power supply).

LCE
Principal

There's still the open question:

How does the external reference voltage of 3.0 V affect the temperature sensor?

I can't find anything in the datasheet or RM, although it makes sense that the result has to be multiplied by 3.0/3.3.

But maybe there are other effects, like the TS cal values stored in flash don't make sense anymore?

> How does the external reference voltage of 3.0 V affect the temperature sensor?

In the same way as for any other ADC measurement. What you want to measure is the temperature sensor's voltage; for that you take ADC reading and then convert it into voltage by using the reference voltage.

Also, if you want to use the constants stored in system memory, for 'H733 they have been taken for VREF=3.3V (the DS partially incorrectly says VDDA=3.3V), so you have to take that into consideration when using them in calculation, too.

waclawekjan_0-1719484422949.png

JW

LCE
Principal

Quick test, changed Vref to 3.3V, and the temperature looks good again.

It seems I have to check @waclawek.jan 's document with the formula, it's definitely not only * 3 / 3.3...

Vref = VDDA = 3.3 V
VRefi 1.2V	1.217 V / 1501
MCU Temp	37.17 ℃ / 788 / 788

 

LCE
Principal

@waclawek.jan 's document showed me the solution:

yes, it is a simple correction factor 3.0 (used Vref) / 3.3 (Vref at factory calibration), but it has to be applied to the raw ADC output from the temperature sensor.

BIG THANKS again to Jan!

PS: a few non-ST guys here should be paid by ST!

STOne-32
ST Employee

Dear @LCE  @waclawek.jan ,

 

Thank you very much for the spotting that issue and formula in our reference manual which is only valid for VDDA=VREF+=3,3Volts , another case is here and will be fixed On chip temperature sensing dependant on Vref - STMicroelectronics Community

 

Thanks again

STOne-32.