GPIO_PinAFConfig does not configure alternate function register
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2012-04-12 2:01 PM
Posted on April 12, 2012 at 23:01
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);
This discussion is locked. Please start a new topic to ask your question.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2012-04-12 2:09 PM
Posted on April 12, 2012 at 23:09
Ok, realized my problem.
It should be: GPIO_PinAFConfig(GSM_TXD,GPIO_PinSource9
, GPIO_AF_USART1); and not: GPIO_PinAFConfig(GSM_TXD,GPIO_Pin9
, GPIO_AF_USART1);