cancel
Showing results for 
Search instead for 
Did you mean: 

How to make sure ADC reading get correct values in a single conversion done in a for loop?

microGen
Associate

I have a code that reads 12-bit ADC value from PA1 of STM32F0. I manage to get the voltage reading right when I just get it from a DC voltage but with an AC voltage produced from an op amp, the values that are stored from the reading consists of a lot of zeros and max values based on the Vref. The way I get the values are by reading ADC value from the pin in a single conversion sequence and continue calling ADC_read in a for loop for 1000 times to get 1000 samples hoping that it would be enough for me to get at least period between one rising edge to another. I assume the readings are wrong since the min and max shown on my oscilloscope is min of 2.5V and max of 2.7V. May I know what is causing the problem here? Is it because the clock is too fast?

2 REPLIES 2

> lot of zeros

The you definitively doing something completely wrong.

Follow the procedures outlined in RM0091 chapter ADC.

JW

PS Please change your username to a normal nick.

I have followed the ref manual. I did get the correct reading for a stable voltage such as voltage reading from temperature sensor. The problem occurs with AC voltage.