2024-05-06 01:32 AM
Hello, I am trying to calculate the internal CPU temperature on an STM32H743, When reading the internal CPU temperature sensor using ADC3 IN18 (internal temperature), I get a very high value (~731C)
The formula I'm using is the following :
Temperature (in °C) = (110 °C – 30 °C) / (TS_CAL2 – TS_CAL1) * (TS_DATA – TS_CAL1) + 30 °C
Here is the algorithm to read the temp :
Here is the code :
MX_ADC3_Init();
HAL_ADCEx_Calibration_Start(&hadc3,ADC_CALIB_OFFSET_LINEARITY, ADC_SINGLE_ENDED);
HAL_ADC_Start_DMA(&hadc3, (uint32_t *)&DMABuff[0], 11);
HAL_TIM_Base_Start_IT(&htim6);
const uint16_t* ADC_TEMP_3V3_30C = (uint16_t*)(0x1FF1E820);
const uint16_t* ADC_TEMP_3V3_110C = (uint16_t*)(0x1FF1E840);
float adcCalTemp30C = (float) (*ADC_TEMP_3V3_30C);
float adcCalTemp110C = (float) (*ADC_TEMP_3V3_110C);
float32_t Temperature = (110 – 30 ) / (adcCalTemp110C – adcCalTemp30C ) * (DMABuff[10] – adcCalTemp30C ) + 30;
I don't know if I missed something that has to be included?
Kind regards
Anas,
2024-05-06 01:47 AM
Hi,
did you set Tsen ?
2024-05-06 02:18 AM
Hello, thanks for the reply
Yes indeed I set the TSEN with the following :
ADC3_COMMON->CCR |= ADC_CCR_TSEN;
And then I run the calibration
2024-05-06 06:01 AM
@AScha.3 It is still showing the same output even thought I enabled TSEN
ADC3_COMMON->CCR |= ADC_CCR_TSEN;
HAL_ADCEx_Calibration_Start(&hadc3,ADC_CALIB_OFFSET_LINEARITY, ADC_SINGLE_ENDED);
Any ideas ?
many thanks
2024-05-06 06:22 AM
What values you get from ADC real ? (in hex)
2024-05-06 07:01 AM
Dear @AScha.3,
With the following ADC value inside DMABuff (0x7f08):
I get
2024-05-06 07:38 AM
>ADC (in mV) = 2413.89
from ds :
-> thats about 4x the value you should get !
So whats your VDDA + Vref ?
+
In Cube, adc setup, you set to : 16bit , no oversampling, no shift ?
2024-05-06 07:52 AM
@AScha.3, appreciate the fast replies
I define :
CALIBRATION_REFERENCE_VOLTAGE as 3.3V
REFERENCE_VOLTAGE 3.0V // supplied with Vref+ or VDDA
Then :
adcCalTemp30C = (float) (*ADC_TEMP_3V3_30C) / (REFERENCE_VOLTAGE/CALIBRATION_REFERENCE_VOLTAGE);
adcCalTemp110C = (float) (*ADC_TEMP_3V3_110C) / (REFERENCE_VOLTAGE/CALIBRATION_REFERENCE_VOLTAGE);
And also here is how I set the ADC3 in Cube
2024-05-06 08:08 AM
So whats your AVDD and VREF+ ? check with DMM at the connected pins.
+
Try ADC settings : overrun data overwritten .
2024-05-07 01:39 AM
@AScha.3
I've checked VREF+ and VDD with DMM
VREF+ = 3.0 V
VDD = 3.36 V
I've changed the ADC settings to OVERRUN DATA OVERWRITTEN with :
hadc3.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN;
and it didn't fix it
Any ideas ?