cancel
Showing results for 
Search instead for 
Did you mean: 

ADC channels and GPIO pins: STM32F407xx

juergen239955_stm1
Associate II
Posted on September 06, 2012 at 23:45

Dear colleagues,

 

       I'm presently looking at the ADC routines in the Standard Peripheral Libraries, and they're pretty well written and documented; what I'm failing to understand so far is how the GPIO pins and the ADC registers are lined up.

        To elaborate, in the example ''ADC/DualADC_RegulSimu_DMAmode1'', I set the pins 0,1,2 from the ''C''-peripheral to analog IO using the lines

    // pins 0,1,2

 

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2;

 

    // analog mode for ADC/DAC

 

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;

 

  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;

 

    // use peripheral ''C''

 

  GPIO_Init(GPIOC, &GPIO_InitStructure);

, which sets the correct bits in the registers GPIOC_MODER, OTYPER, and OSPEEDR. So far, so good. Then, I set the up two ADC peripherals with two conversions each:

 

  ADC_RegularChannelConfig(ADC1, ADC_Channel_10, 1, ADC_SampleTime_3Cycles);

 

 

  ADC_RegularChannelConfig(ADC1, ADC_Channel_11, 2, ADC_SampleTime_3Cycles);

  ADC_RegularChannelConfig(ADC2, ADC_Channel_11, 1, ADC_SampleTime_3Cycles);

 

 

  ADC_RegularChannelConfig(ADC2, ADC_Channel_12, 2, ADC_SampleTime_3Cycles);

It all works fine, but I haven't found the link between the ADC channels 10,11,12 and the GPIO pins C0,1,2. Explanations either in the context of the standard peripheral library or the registers would be appreciated.

Thanks and Best Regards,

JJ

2 REPLIES 2
raptorhal2
Lead
Posted on September 11, 2012 at 03:13

The answer is simpler than that. Look at the table of pin assignments in the datasheet.

Cheers, Hal

juergen239955_stm1
Associate II
Posted on September 12, 2012 at 00:01

Hal,

      yup, very obvious. Thanks!

JJ