Skip to main content
Graduate
November 28, 2023
Question

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

  • November 28, 2023
  • 2 replies
  • 2109 views

I cant find any reference to these numbers.

    This topic has been closed for replies.

    2 replies

    Graduate II
    November 28, 2023

    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:

    https://www.st.com/resource/en/reference_manual/dm00031020-stm32f405-415-stm32f407-417-stm32f427-437-and-stm32f429-439-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf

    Technical Moderator
    November 28, 2023

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

    STTwo32_0-1701173548944.png

     

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

    Best Regards.

    STTwo-32

    TobeAuthor
    Graduate
    November 28, 2023

    Thanks.

    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!

     

    Graduate II
    November 28, 2023

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