cancel
Showing results for 
Search instead for 
Did you mean: 

Setting up pins for alternative functions of STM32F411 MCU

Mykola_Levun
Associate III

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

 

7 REPLIES 7
TDK
Super User

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".
Pavel A.
Super User

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.

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

 

 

> 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".

For UART, for RX pin, can I select any mode from 6 possible (see figure bellow)?

Mykola_Levun_0-1750169111938.png

 

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.

If you feel a post has answered your question, please click "Accept as Solution".

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."