cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L476RG ADC readings strange behaviour

MThom.3
Associate

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:

0693W00000aIusJQAS.pngThe 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:

0693W00000aIuoRQAS.pngBlue 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:

0693W00000aIuqNQAS.png 

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.

1 ACCEPTED SOLUTION

Accepted Solutions

> 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

View solution in original post

2 REPLIES 2

> 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

MThom.3
Associate

Hi,

Thanks for the fast answer. After adding a buffer between the pot and the analog read values are fine!