# STM32H7 on-chip temperature sensor reading stable on 'Y' revision, but unstable on 'V' revision chip

using the STM32H753VIT6, I like to monitor the on-chip temperature sensor. The environmental temperature can become about 50 degrees Celsius, and the board is housed is a small plastic (DIN-rail) enclosure. This enclosure is fitted in a metal cabinet.

The measurement worked stable on a revision 'Y' of the STM32H7, but now I finally got the recommended revision 'V' of the MCU, where the reading is very unstable, when reading every second. It may vary more than 15 degrees Celsius between two readings.

The board design did not change.

On the other hand, there are differences between the ADC peripheral registers between the 'Y' and 'V' versions. I have read AN5312 Migration from RevY to RevV for STM32H7xx Value line microcontrollers: https://www.st.com/resource/en/application_note/dm00609692.pdf

And I also checked the errata sheet: https://www.st.com/resource/en/errata_sheet/dm00368411.pdf

Is anybody able to get stable reading from the internal temperature sensor?

    /* ADC3 init function */
{

/* Common config */
{
Error_Handler();
}
/* Configure Regular Channel */
sConfig.Offset = 0;
{
Error_Handler();
}
}


Initialization function:

void DMC_MCU_TemperatureInit(void)
{

}


The value is read from the interrupt:

ADC_Value = HAL_ADC_GetValue(&hadc3);


The calculation done on the value:

uint16_t DMC_MCU_TemperatureCalculate(uint32_t ts_data)
{
// 0x1FF1E820 Calibration ADC value at 30 °C = 0x2fc0, 12224
uint16_t ts_cal1 = *(uint16_t*) (TS_CAL1_REG);
// 0x1FF1E840 Calibration ADC value at 110 °C = 0x3cb4, 15540
uint16_t ts_cal2 = *(uint16_t*) (TS_CAL2_REG);

return (80 * (ts_data - ts_cal1)) / (ts_cal2 - ts_cal1) + 30;
}


I tried different values for ClockPrescaler and SamplingTime as well as different PLL settings for the ADC, but it did not improve.

What can I do to get stable readings, like on the 'Y' version? Any help would be appreciated.

Heavy filtering seems to work, but I wonder if something could be wrong.

I use latest HAL libraries.

Note, maybe we could add the missing tag "stm32h7" (I think, it is not new anymore).

• There are quite a lot of changes between these chip revisions, did you update HAL as well? Be sure to use the very latest version (June 2019, with confusing version numbers), there are apparently some fixes for RevV in there. – berendi - protesting Sep 10 '19 at 9:20
• You have configured the ADC to 16 bit resolution, but truncate the result to whole degrees, using effectively less than 11 bits resolution. Using the ADC in 12 or even 10 bit mode (the latter giving 1.5 degrees accuracy) might give more stable results, still suitable for monitoring the chip temperature. – berendi - protesting Sep 10 '19 at 9:33
• Thank you. Note the calibration values are in 16 bit. I tried to use the ADC in 12 bit mode too, it varies the same amount. The conversion time may be faster, which is not important here. I now use some filtering, which works well enough. – Jack Sep 11 '19 at 8:52
• @Jack - Regarding your point (which really should be a comment and not in the question): "maybe we could add the missing tag "stm32h7"". That is unlikely to happen. Please see this topic and this one on the Meta site. The number of tags for stm32 devices has deliberately been reduced, for the reasons discussed on those pages. – SamGibson Sep 11 '19 at 9:32
• Did you probe Vdda and Vref to check if that is stable? – Jeroen3 Sep 11 '19 at 10:00