2023-03-14 03:43 AM
Hello,
I'm using a STM32L476RG Nucleo board for a personnal project.
While playing with the ADC, I noticed something strange: ADC raw readings seems to be off.
My experiment, connect the middle pin of a 100k potentiometer to the PC0 pin, and record different ADC output code with different voltage.
The code used for the experiment:
The output codes are read using the debug tool in Cube IDE, pausing after reading. Multiples readings are done before selecting a value.
Using excel, I came up with this chart:
Blue line corresponds to the data recorded: ADC output code vs Applied voltage.
Orange line corresponds to the output code I'm supposed to get using the theorical formula: Ouput code = Vin * 4095/3.3 (3.3 being the voltage on the AREF pin, 4095 beiing the max output code possible with a 12 bit ADC).
By playing with the formula, I found out a reference voltage that could give me a theorical curve close to my practical one in the 3.7V-3.8V range:
Blue line is the same as before, while orange line correspond to the output code i'm supposed to get using the formula: Output code = Vin/3.8*4095.
The issue is that the MUC isn't capable of handling a 3.8V as his analog reference voltage, and that I checked the analog reference voltage on the board: 3.32V.
Nevertheless, the ADC will still give me a full scale output code (0xFFF) at 3.3V.
Is there an explanation to such a weird behaviour of the ADC?
Thanks to everyone that read up to there.
Solved! Go to Solution.
2023-03-14 04:54 AM
> connect the middle pin of a 100k potentiometer to the PC0 pin
That's a too high impedance source. Read the ADC characteristics in datasheet.
JW
2023-03-14 04:54 AM
> connect the middle pin of a 100k potentiometer to the PC0 pin
That's a too high impedance source. Read the ADC characteristics in datasheet.
JW
2023-03-14 12:32 PM
Hi,
Thanks for the fast answer. After adding a buffer between the pot and the analog read values are fine!