cancel
Showing results for 
Search instead for 
Did you mean: 

Configure AF GPIO register using 11U STM32F446RE

StanCosgrove
Associate II

Hi, i came across a program to config alternation function for SPI GPIO port A. 

GPIOA->CRL |= (11U<<20);       // PA5 SCK AF output push pull

GPIOA->CRL |= (11U<<28);       // PA7 MOSI AF output push pull

What does the 11U means? i know its something like setting the 20th bit to 11? is 11 the binary value for 3? how does the value 3 relates to PA5 SCK and 28 relates to PA7 MOSI ?  Anyone can advise?

12 REPLIES 12

STM32F446RE

yes i agree,  no GPIOx_CRL registers in RM0390. 

Reset value, that is value after reset, of that register is 0x44444444; it means, CNF5=0b01, MODE5=0b00. If you OR that value with 0b1011, CNF5=0b01 OR 0b10 = 0b11; MODE5 = 0b11.

All this is relevant only for 'F1, i.e. irrelevant for 'F446; however, corollary remains, namely that you have to take into account the reset value of register when doing only ORs to set some of the bits.

JW