2017-06-01 09:53 AM
Hello to the community,
Due to an error on a board routing I have ended with a bunch of boards with the RX and TX pins of USART1 incorrectly routed to PB4 and PB5 pins of STM32F103.
I wonder if there is any human way of remaping this pins to be used with USART1,2 or 3.
I have tried the following code without success:
#define USARTy USART2
#define USARTy_GPIO GPIOB #define USARTy_CLK RCC_APB1Periph_USART2 #define USARTy_GPIO_CLK RCC_APB2Periph_GPIOA #define USARTy_RxPin GPIO_Pin_4 #define USARTy_TxPin GPIO_Pin_5RCC_APB2PeriphClockCmd(USARTy_GPIO_CLK | RCC_APB2Periph_AFIO, ENABLE);
RCC_APB1PeriphClockCmd(USARTy_CLK, ENABLE);
/* Enable the USART2 Pins Software Remapping */
GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE);
/* Configure USARTy Rx as input floating */
GPIO_InitStructure.GPIO_Pin = USARTy_RxPin; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(USARTy_GPIO, &GPIO_InitStructure);/* Configure USARTy Tx as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = USARTy_TxPin; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(USARTy_GPIO, &GPIO_InitStructure);Thanks in advance,
Luis
2017-06-01 05:23 PM
The silicon provides a finite set of connections, so what you want to happen, can't.
You'd perhaps look at implementing a Software USART, but this isn't something I'd recommend.
2017-06-02 12:56 AM
Thank you, this is what I was expecting, having read the reference manual about remaping uarts seemed to have this hardwired. I just was hoping to have missed anything.
Thank you again.