cancel
Showing results for 
Search instead for 
Did you mean: 

CMSIS STM32F4 setting AFR register

Mark Higham
Associate
Posted on June 04, 2017 at 04:37

There doesn't seem to be any bit definition for the GPIO AFR registers. I can set the PA5 pin alternate function to AF1 using the below code but other registers seems to have bit definitions to use. Am I missing them?

GPIOA->AFR[0] |= 0x00100000;

1 REPLY 1
Posted on June 04, 2017 at 23:56

Each pin has a 4-bit mux value, so 4x16 = 64-bits, spread over two 32-bit AFR words

The mux table is in the Data Sheet, see pin table with pins down the side, and AF value across the top.

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