2020-08-19 03:33 PM
Hi,
I'm using the STM32F091RC-Nucleo ADC sequencer example to understand the ADC initialization but I'm not getting accurate results. It looks like the example uses PA4 on the board:
/* main.h */
#define ADCx_CHANNELa_GPIO_PORT GPIOA
#define ADCx_CHANNELa_PIN GPIO_PIN_4
I have a power supply connected to a PA4 and when I adjust the voltage from the 0 -> 3.3 volts (which should be Vref for the ADC), I get meaningless results. These are the results for the ADC values read at PA4, when I apply 1.0 V:
/* main.c */
uhADCChannelToDAC_mVolt = COMPUTATION_DIGITAL_12BITS_TO_VOLTAGE(aADCxConvertedValues[0]);
1441
1441
1437
1438
1444
And these are the values read when I apply 2.0 V:
1432
1428
1427
1427
1437
The ADC readings are effectively the same for 1.0 volts or 2.0 volts.
Can anybody advise on what's going wrong?
2020-08-19 05:02 PM
> I have a power supply connected to a PA4
Is your power supply ground connected to the board ground as well?
You could also just connect PA4 to GND or 3V3 to test.
2020-08-20 03:49 AM
Yes, the power supply ground is connected to the board ground. I connected 3.3 volts from the board to PA4 and these are the results (I'm expecting something close to 4095 - full-scale):
1728
1797
1854
1793
1831
And these are the readings when ground is connected (I'm expecting something close to 0):
1824
1757
1809
1874
1769
2020-08-24 04:25 AM
Can anyone advise on how to debug this issue? I imagine that the hardware on the Nucleo boards is correct.
2020-08-24 07:10 AM
You haven't really posted enough information to debug. Clearly something is wrong, probably in code, but it's not any of the 3 lines of source you've provided.
2020-08-24 07:13 AM
I've posted that "I'm using the STM32F091RC-Nucleo ADC sequencer example" (it's the first line in the post), and I'm targeting the STM32F091RC-Nucleo development board. Should I post the relevant initialization from the example? Those lines are posted were from where I was extracting the ADC readings.