2012-09-06 02:45 PM
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,2GPIO_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
2012-09-10 06:13 PM
The answer is simpler than that. Look at the table of pin assignments in the datasheet.
Cheers, Hal2012-09-11 03:01 PM
Hal,
yup, very obvious. Thanks!JJ