Unable to read ADC properly using STM32L073VZI6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-08 3: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.
- Labels:
-
ADC
-
STM32L0 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-09 9:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-08 6: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-09 1: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-09 9:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-09 9: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-09 2: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-10 4:22 PM
Read the AN4467.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-14 4:54 AM
Thank you all, connecting VREF+ to Vdd fixed it.
