2025-06-17 5:24 AM
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.
2025-06-17 5:54 AM
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.
Alternate function numbers are listed in the datasheet.
2025-06-17 5:54 AM
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.
2025-06-17 6:32 AM
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?
2025-06-17 6:39 AM
> 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.
2025-06-17 7:05 AM - edited 2025-06-17 7:06 AM
For UART, for RX pin, can I select any mode from 6 possible (see figure bellow)?
2025-06-17 7:16 AM
Yes. PP/OD has no effect since the pin is input. Since RX is typically idle high, you should usually choose no pull resistor or an internal pullup.
2025-06-17 8:50 AM
The most important information was posted by TDK earlier and will be a surprise to F103 users:
"Alternate function numbers are listed in the datasheet."