cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H723 Internal Temperature Measurement vs. Ambient

ToddA
Associate II

All:

Setup - STM32H723 with VREFP = 3.00 V

I have connected internal temperature to ADC3, and I am able to display degrees C on "Live Expressions". With VREFP set to 3.00 V, I am seeing lower readings than ambient. Using __HAL_ADC_CALC_TEMPERATURE( ), I am seeing internal temperatures of 21 - 24 C, vs. ambient temperature of 25.8 C.

Is there a variation based on VREFP? (Earlier on Nucleo board, I was seeing internal temperature of 30 C with VREFP of 3.3 volts.)

Regards,

Todd Anderson

 

1 ACCEPTED SOLUTION

Accepted Solutions
LCE
Principal

The results I get from H723-Nucleo / H735-Discovery make sense.
I use slowly running ADC 3, I think VDDA / VREF on these boards is VCC = 3.3V.

I calculate it like this:

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

/* 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;
}

This might be the same as yours, but I'm too lazy to check! ;)

flAdcTemp is just an averaged value of the ADC samples, so it's somewhere between 0.0 .. 4095.0.

View solution in original post

6 REPLIES 6

I'd expect the temperature sensor being supplied by VDDA rather than VREF+.

Of course, VREF+ has impact on ADC itself.

OTOH, the temperature sensor is far from being precise; a couple of degrees C deviation is to be expected.

Here is a relatively generic checklist of things which may go wrong, you may want have a look at it, just to be sure.

JW

I tried the following algorithm based on the reference manual, not sure if results are accurate.

Temperature (C) = ( ( TS_CAL2_TEMP - TS_CAL1_TEMP) / (TS_CAL2 - TS_CAL1) ) x (TS_DATA - TS_CAL1) ) 

                              + 30 C.

TS_CAL2_TEMP = 130

TS_CAL1_TEMP = 30

TS_CAL2 = 0x401 (from memory location) = 1025

TS_CAL1 = 0x306 (from memory location) = 774

CAL2_TEMP - CAL1_TEMP = 100 C

TS_CAL2 - TS_CAL1 = (1025 - 774) = 251

1st term = 100 / 251 = 0.398

Resulting equation:  Temperature (C) = (  (0.398) x (TS_DATA - 774) )  +  30 C

my data reading was 820 counts, so my Temperature (C) = ( (0.398) x ( 820 - 774) ) + 30

                                                                                            =  (0.398 x 46 ) + 30

                                                                                            =  18.3 + 30

                                                                                            = 48.3  internal temperature

Hopefully, the math is correct and that is a reasonable expectation. Tell me if there are flaws in my calculations...

 

 

You have to take into account difference between your VREF+ voltage and the voltage at which TS_CALx has been taken.

If your VREF+ is 3.0V and the datasheet values were taken at 3.3V, TS_CAL1 -> 1025 / 3.0 * 3.3 = 1127.5; TS_CAL2-> 774 / 3.0 * 3.3 = 851.4. Your readout is below TS_CAL1 so it will correspond to cca 18.6deg.C

That's somewhat suspicious.  Try go through the steps in checklist (GND cleanness on all related pins, VREF+ stability and exact value, proper ADC calibration, settling times; also check against internal reference VREFINT or other known precise voltage source); try to repeat on the "known good" board.

JW

 

Thanks, Jan

This makes sense. So far the processor is not working really hard, so a few degrees above ambient is not out of the question. I will look into this further.

Regards,

Todd Anderson

I needed to adjust the sample time to slow it down for reading temperature. It is now closer, but still a little below ambient. This will be as good as I can get with a VREF that is not 3.3 volts.

Todd Anderson

LCE
Principal

The results I get from H723-Nucleo / H735-Discovery make sense.
I use slowly running ADC 3, I think VDDA / VREF on these boards is VCC = 3.3V.

I calculate it like this:

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

/* 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;
}

This might be the same as yours, but I'm too lazy to check! ;)

flAdcTemp is just an averaged value of the ADC samples, so it's somewhere between 0.0 .. 4095.0.