Alternate Functions (GPIO)




Programming Instructions

Depending on the alternate function you have to configure the pins as:


Configuration Registers

GPIOx_MODER - Mode register




Pin x10Alternate function mode

GPIOx_AFRL/H - Alternate function register (low / high)







Pin x0000AF0: RTC, MCO, Tamper, SWJ, Trace
0001AF1: Timer 1, Timer 2
0010AF2: Timer 3..5
0011AF3: Timer 8..11
0100AF4: I²C 1..3
0101AF5: SPI 1..6
0110AF6: SPI 2/3, SAI 1
0111AF7: SPI 3, USART 1..3
1000AF8: USART 6, UART 4/5/7/8
1001AF9: CAN 1/2, Timer 12..14, LCD
1010AF10: USB OTG HS/FS
1011AF11: Ethernet
1100AF12: FMC, SDIO, USB OTG FS
1101AF13: DCMI
1110AF14: LCD
1111AF15: Event Out

GPIOx_PUPDR - GPIO port pull-up / pull-down register




Pin x00No pull-up, pull-down (reset state)
01Pull-up
10Pull-down
11Reserved

GPIOx_OTYPER - Port output type register




Pin x0Output type: push-pull (reset state)
1Output type: open-drain

GPIOx_OSPEEDR - Port output speed register




Pin x00Speed: 2 MHz (reset state)
01Speed: 10 MHz
10Speed: 50 MHz
11Speed: 100 MHz