2022-11-08 03:45 AM
Hello,
I am using STM32L073VZI6 in a custom board, trying to read ADC values from a potentiometer connected to PA6. The microcontroller and the potentiometer are powered with 3.3 V.
The issue is that I get 4095 when the voltage input is less than 2 V. From 2 V to 3.3 V still I get 4095. Below are the configuration and the code. I have tried already many combinations without success.
Any help will be much appreciated.
Solved! Go to Solution.
2022-11-09 09:02 AM
2022-11-08 06:17 AM
The ADC needs to be calibrated before you use it on the L0 series. Are you doing that? It's not done in the code you posted.
What is your VREF+ and how is it powered/connected?
How much impedance does your signal have? (i.e. what is the potentiometer resistance)
1.5 cycle sampling time isn't much. Probably not the issue, but increasing that for accuracy is probably smart.
2022-11-09 01:04 AM
Hi TDK,
Thanks for your reply.
I am already using "while(HAL_ADCEx_Calibration_Start(&hadc,ADC_SINGLE_ENDED) != HAL_OK);" before reading the adc.
VREF is connected in this way
The potentiometer resistance is 5 kohms
1.5 cycle is the last value I tested, but I tried other values.
Thank you
2022-11-09 09:02 AM
2022-11-09 09:22 AM
I thought it was optional, probably I misunderstood the datasheet. I will test it with the modification in a few days (unfortunately) and let you know.
Many thanks
2022-11-09 02:06 PM
For precise measurements it's also recommended to source Vdda from Vdd through ferrite bead (smd ones do just fine). I never do though, but in my area 10-20% tolerance is fine. Or separate LDO.
2022-11-10 04:22 PM
Read the AN4467.
2022-11-14 04:54 AM
Thank you all, connecting VREF+ to Vdd fixed it.