Skip to main content
Associate III
June 17, 2025
Question

Setting up pins for alternative functions of STM32F411 MCU

  • June 17, 2025
  • 2 replies
  • 816 views

Hello,

STM32F411 microcontroller.
Where can I find what mode (input/output or pull-up/pull-down) to configure the GPIO for alternate functions? For example, for UART or SPI and so on.
For example, for STM32F103 microcontroller, there are tables that help you select the appropriate GPIO settings for alternate functions (UART or SPI and so on) in the Reference manual. For STM32F411 microcontroller, there are not tables that help you select the appropriate GPIO settings for alternate functions (UART or SPI and so on) in the RM0383 Reference manual. There are this information (see figure bellow) in the RM0383 Reference manual, but there are no such clear tables as for the STM32F103 microcontroller.

Mykola_Levun_0-1750162954901.png

 

2 replies

TDK
Super User
June 17, 2025

To use an AF mode, you set the pin to AF mode in the MODER register and set the alternate function to what you want in the AFL/AFH register. The pullup/pulldown and pin speed is at your discretion.

TDK_0-1750164780058.png

 

TDK_1-1750164794889.png

 

Alternate function numbers are listed in the datasheet.

TDK_2-1750164858374.png

 

"If you feel a post has answered your question, please click ""Accept as Solution""."
Associate III
June 17, 2025

For the STM32F103 microcontroller, there is  9.1.11 GPIO configurations for device peripherals section (see 2 figures bellow) that help you select the appropriate GPIO settings for alternate functions (UART or SPI and so on) in the RM0008 Reference manual. Why is similar section not representing in the RM0383 Reference manual for the STM32F411 microcontroller? How do I know how to configure the pins for the peripherals for the STM32F411 microcontroller?

Mykola_Levun_0-1750167022484.pngMykola_Levun_1-1750167070372.png

 

 

TDK
Super User
June 17, 2025

> Why is similar section not representing in the RM0383 Reference manual for the STM32F411 microcontroller? How do I know how to configure the pins for the peripherals for the STM32F411 microcontroller?

On the F4, pins are ALWAYS in AF mode for alternate functions. Never input mode. The F1 is different which is why the table is there. Open-drain or push pull is depending on your needs. Either one works. Some, like I2C, need to be open-drain as that is how the bus works.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Pavel A.
Super User
June 17, 2025

For STM32F4 just leave the AF pins in no pull-up & no pull-down state, unless your hardware engineer tells otherwise. The "speed" (or more correctly, strength of the drive) is important. It defines the rising/falling times of the signals. Do not set very high - unless it is justified. Too high drive can cause ringing and distortion of signals.