Showing results for 
Search instead for 
Did you mean: 

What are the numbers on Alternate functions AF1, AF2, ...?

Senior III

I cant find any reference to these numbers.


Its the pin function setting.

i.e. if you want PA1 (in your example) to use UART then you have to select Alternate Function 7. A different pin function e.g. I2C will be a different Alternate Function.

The value you select is loaded into the GPIOx_AFRL / GPIOx_AFRH registers.

See page 272 of RM090 for an explanation of Alternate Function GPIO Multiplexing:

ST Employee

Hell @Tobe @###### 

AFx represent as said @###### the alternate function number x. you can configure a pin for a specific AFy by writing y to specific 4 bits of the:

  • GPIOx_AFRLx if the pin is pin n (n = 7 to 0) 
  • GPIOx_AFRHx if the pin is pin n (n = 8 to 15).



For more details, take a look at the RM0440. pages 365/366

Best Regards.


To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.


I have searched in the wrong Datasheet. There i could not find the meaning of the AF numbers. I really dont like having two datasheets!


The Data Sheet/Manual covers the pin level stuff as there are multiple packages with different pins and sizing.

The Reference Manual covers a lot of the general die / family level stuff, the registers and peripherals, some of which won't escape from smaller packages.

They've been doing this for more than a decade, don't anticipate this strategy changing.

Probably shouldn't mention the Programming Manual..

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..