2025-06-12 12:10 AM - last edited on 2025-06-13 7:22 AM by Andrew Neil
Hi,
we are using ADC with DMA for internal ADC channel like internal Temperature sensor, VBAT, VREF but we are facing issue related to accuracy please help me on this Configuration:
ADC channel:
2025-06-12 6:28 AM
A few things:
2025-06-12 11:13 PM
Are you calibrating the ADC before using it? You need to.
ANS: Yes
What chip are you using?
ANS: STM32H743ZIVET6
What raw ADC values do you get?
ANS: During debugging we could read the below calibration values and ADC raw count.
TS_CAL2 = 16287, TS_CAL1 = 12805.
Temperature raw count = 2877
Vbat raw count = 2760
You're using 130 for the upper end temperature instead of 110 as the comments say.
ANS:
As per the Datasheet of STM32H743ZI, an internal MCU temperature sensor connected to ADC3_INP18 channel is factory calibrated and below are the calibration values stored into the MCU internal Flash.
Below formula will be used for actual temperature calculation. Where TS_DATA is the actual temperature sensor output value converted by ADC. also mention this formula in code above
At room temperature, it is expected to get the value of TS_DATA between TS_CAL1 & TS_CAL2 or near around TS_CAL1. But we are getting TS_DATA = 2877 & calculated temperature = -198.098
For Vbat,
ADC count for Vbat/4 = 2760, formula used to calculate battery volt = 4 * 3.3 * Vbat raw count / 65535 , where 4 is multiplying factor for ADC count Vbat /4, 3.3 V is VDDA, 65535 is for 16 bit ADC resolution.
Hence Calculated Vbat = 0.56V
Measured Vbat pin voltage on STM32H743ZI Nucleo board is 3.25V.
2025-06-12 11:33 PM
Are you calibrating the ADC before using it? You need to.
ANS: Yes
What chip are you using?
ANS: STM32H743ZIVET6
What raw ADC values do you get?
ANS: During debugging we could read the below calibration values and ADC raw count.
TS_CAL2 = 16287, TS_CAL1 = 12805.
Temperature raw count = 2877
Vbat raw count = 2760
You're using 130 for the upper end temperature instead of 110 as the comments say.
ANS:
As per the Datasheet of STM32H743ZI, an internal MCU temperature sensor connected to ADC3_INP18 channel is factory calibrated and below are the calibration values stored into the MCU internal Flash.
Below formula will be used for actual temperature calculation. Where TS_DATA is the actual temperature sensor output value converted by ADC. also mention this formula in code above
At room temperature, it is expected to get the value of TS_DATA between TS_CAL1 & TS_CAL2 or near around TS_CAL1. But we are getting TS_DATA = 2877 & calculated temperature = -198.098
For Vbat,
ADC count for Vbat/4 = 2760, formula used to calculate battery volt = 4 * 3.3 * Vbat raw count / 65535 , where 4 is multiplying factor for ADC count Vbat /4, 3.3 V is VDDA, 65535 is for 16 bit ADC resolution.
Hence Calculated Vbat = 0.56V
Measured Vbat pin voltage on STM32H743ZI Nucleo board is 3.25V.
2025-06-13 3:34 AM
Hello @DhirajThakur,
Since the issue is related to TS_DATA value (very low), and this value is converted by ADC, most probably the issue is related to the ADC configuration; try using a longer sampling time for the internal temperature sensor.
Another thing is in your formula: Vbat= 4 * 3.3 * Vbat raw count / 65535 where VDDA= 3.3
Depending on the package VDDA can be internally connected to Vref+ or not, could you specify the package you're using!
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-06-13 6:50 AM
> ADC_REGULAR_RANK_8
If converting 3 channels, they should be on ranks 1-3. Or maybe 0-2, not sure if it's base 0 or 1.
I have to believe the issue is in how the ADC is being configured. Doesn't look like you're using HAL. Ensure the SQRx registers point to the correct channels.
> ADC_SAMPLETIME_8CYCLES_5
Unlikely to be long enough for VREFINT or VBAT. Required sampling duration is in the datasheet.