Skip to main content
wesleyklhk
Associate II
March 21, 2014
Question

how to configure 2 analog inputs for adc?

  • March 21, 2014
  • 5 replies
  • 1284 views
Posted on March 21, 2014 at 15:13

Hi guys,

I am a beginner and just start playing around with the board. I need some help on configuring 2 analog inputs for adc3. I already looked at the peripheral example. It seems like it is only configured for 1 pin. Also, I have a question regarding to the adc dma example. In the example, PC2 is configured as an analog input. How do you know that PC2 is connected to ADC3 channel12? If i have 2 analog inputs, do I just pick random 2 pins and hook it up 2 random channels? By the way, I am using stm32f4discovery. Please advice. Thank you.

#rtfm #!random-shit #analog-inputs-for-adc
    This topic has been closed for replies.

    5 replies

    Tesla DeLorean
    Guru
    March 21, 2014
    Posted on March 21, 2014 at 15:22

    If i have 2 analog inputs, do I just pick random 2 pins and hook it up 2 random channels?

    No, you review the

    http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/DM00037051.pdf

    for the part and review the pin and function designations.

    You'd review the

    http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00039084.pdf

    for the STM32F4-DISCO to understand what pins are free to use.

    [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Discovery/Multi%20Channel%20ADC%20reading&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&currentviews=1054]https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FSTM32Discovery%2FMulti%20Channel%20ADC%20reading&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F¤tviews=1054
    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    wesleyklhk
    Associate II
    March 21, 2014
    Posted on March 21, 2014 at 15:28

    are you referring to the alternate function pins? but the example does not configure any pins as alternate function.

    wesleyklhk
    Associate II
    March 21, 2014
    Posted on March 21, 2014 at 15:33

    Could you tell me where in the manual that tells me the mapping from a GPIO pin to an adc channel? I am having a hard time finding it.

    Tesla DeLorean
    Guru
    March 21, 2014
    Posted on March 21, 2014 at 15:40

    Analogue functions are treated slightly differently than Digital AF/GPIO ones

    0690X00000605XsQAI.png

    //******************************************************************************
    void GPIO_Configuration(void)
    {
    GPIO_InitTypeDef GPIO_InitStructure;
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
    /* Configure ADC1 Channel3 & 5 pins as analog input ******************************/
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_5;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
    GPIO_Init(GPIOA, &GPIO_InitStructure);
    }
    //******************************************************************************

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    wesleyklhk
    Associate II
    March 21, 2014
    Posted on March 21, 2014 at 15:41

    thank you so much