cancel
Showing results for 
Search instead for 
Did you mean: 

GPIO AF mode

ybitton
Associate II
Posted on June 06, 2011 at 09:35

Hi,

Lets say i want to connect analog signal to ADC channel12 (which is default pin is PORTC-2).

Should i configure GPIOC-2 mode as: GPIO_Mode_AIN or GPIO_Mode_AF_OD/PP?

I suppose GPIO_Mode_AIN, so when do i use GPIO_Mode_AF_OD/PP?

Thanks - Udi 

#gpio-mode
4 REPLIES 4
Andrew Neil
Evangelist
Posted on June 06, 2011 at 09:51

''when do i use GPIO_Mode_AF_OD/PP?''

 

When you have an

A

lternate

F

unction that requires

O

pen-

D

rain or

P

ush-

P

ull drive; eg, a USART or I2C...?

ybitton
Associate II
Posted on June 06, 2011 at 11:53

Hi Neil,

According to this FAQ: 

http://www.st.com/stonline/faq/faqview.php?ids=1222

AFIO clock should be enabled when doing remap for peripheral pin (and not if it use its default pin), therefore  i asked if the same thing goes for GPIO mode.

Specifically, ADC channel pin should be used as GPIO_Mode_AIN or GPIO_Mode_AF?

 

Thanks - Udi 

donald2
Associate II
Posted on June 06, 2011 at 23:21

The terminology is confusing.

Using a GPIO pin as an input to the ADC converter is clearly an ''alternate function'' by the everyday understanding of that phrase.  But not here.  You set the pin mode to 0, Ain, not to one of the 'Alternate Function' modes, to turn on the analog switch to the ADC and turn off the input buffers.

The ''turn off the input buffers'' is an important phrase.  Anytime there isn't a digital level on a pin, it should be set to pull-up/pull-down (for no connection) or analog input (if something is driving the pin to a middle level, such as the DAC output).

ybitton
Associate II
Posted on June 09, 2011 at 10:08

Thanks Donald, It makes sense.