2025-07-31 3:29 AM
Hi all
I am facing some issue related to measurement of VREFINT and VBAT which is IN17 and IN18 respectively,
My ADC1 configuration is 12 bit resolution, 3cycles sample, one shot and software conversion.
I ran few tests as follows
1.vref which is 2.95 (VDD) and vin is selected as channel IN17 and I am getting 414 in my DR register. (vrefint bit is clear in CCR)
2.vref which is 1.21 (VrefINT) and vin is selected as channel IN17 and I am getting 1702 in my DR register. (vrefint bit is Set in CCR)
3.vref which is 2.95 (VDD) and vin is selected as channel IN18(VBAT) and I am getting 420 in my DR register. (vrefint bit is clear in CCR).
4.vref which is 1.21 (VrefINT) and vin is selected as channel IN18 and I am getting 1679 in my DR register. (vrefint bit is Set in CCR).
help me where I am wrong.
B.R
2025-07-31 4:27 AM
Which STM32 exactly?
For VBAT measurement, you probably need to set ADC_CCR.VBATE . Note, that if your battery is a coin cell, this will drain it, so you don't want to leave it switched on for too long.
> 3 cycles sample
That's probably not enough. Read the datasheet to find out the required timing - after enable, and also for sampling.
JW
2025-07-31 7:03 AM
In addition to @waclawek.jan 's comments, vref+ of 1.21 is likely not okay. I don't see how you can use VREFINT as VREF+ anyway.
4. If VREF+ pin is present, it must respect the following condition: VDDA-VREF+ < 1.2 V.
Probably sampling time is insufficient. Include the schematic if you can.