Skip to main content
Visitor II
August 19, 2020
Question

STM32F091RC-Nucleo ADC Sequencer example not producing correct results

  • August 19, 2020
  • 5 replies
  • 1181 views

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?

    This topic has been closed for replies.

    5 replies

    Super User
    August 20, 2020

    > 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.

    MBill.1Author
    Visitor II
    August 20, 2020

    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

    MBill.1Author
    Visitor II
    August 24, 2020

    Can anyone advise on how to debug this issue? I imagine that the hardware on the Nucleo boards is correct.

    Super User
    August 24, 2020

    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.

    MBill.1Author
    Visitor II
    August 24, 2020

    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.