AnsweredAssumed Answered

GPIO_PinAFConfig does not configure alternate function register

Question asked by potgieter.mc on Apr 12, 2012
Latest reply on Apr 12, 2012 by potgieter.mc
I'm using a STM32L151C8 with ARM RealView and ST peripheral libraries.
When I try and configure an I/O pin as an alternate function it does not write the alternate function selection to the GPIOx_AFR register. After calling the GPIO_PinAFConfig function the GPIOA_AFRH register should contain a value of 0x07 (AF7) in AFRH10 and AFRH9 but they remain zero.

#define USART_TXD_PIN                         GPIO_Pin_9
#define USART_RXD_PIN                         GPIO_Pin_10
#define USART_TXD                             GPIOA
#define USART_RXD                             GPIOA

GPIO_InitStructure.GPIO_Pin = GSM_TXD_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;  
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_PinAFConfig(GSM_TXD, GSM_TXD_PIN, GPIO_AF_USART1);        

GPIO_InitStructure.GPIO_Pin = GSM_RXD_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; 
GPIO_Init(GPIOA, &GPIO_InitStructure);        
GPIO_PinAFConfig(GSM_RXD, GSM_RXD_PIN, GPIO_AF_USART1);

Outcomes