2018-11-13 04:58 PM
Hi,
I want to change TX/PB6 to RX/PB6 for USART1 on STM32F103.
Please let me know if you have a solution.
Thanks.
2018-11-13 05:08 PM
Remap the I2C1 off the PB6/PB7 and then remap USART1 on. For the remap to function the AFIO clock needs to be enabled.
2018-11-13 05:47 PM
Hi Clive
Thanks for quickly response.
You mean that below?
================================================
__HAL_AFIO_REMAP_I2C1_DISABLE();
__HAL_RCC_USART1_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
__HAL_AFIO_REMAP_USART1_ENABLE();
__HAL_RCC_AFIO_CLK_ENABLE();
================================================
Could you let me know the more detail information?
Thanks.
2018-11-13 05:59 PM
You need to enable the AFIO clock BEFORE you use things dependent on it, not after.
Try a more rational ordering..
__HAL_RCC_AFIO_CLK_ENABLE();
__HAL_RCC_USART1_CLK_ENABLE();
__HAL_AFIO_REMAP_I2C1_DISABLE();
__HAL_AFIO_REMAP_USART1_ENABLE();
2018-11-14 12:41 AM
I tried it in the way you told me, but it did not work
In my pins configuration,
1. I2C1 = not use
2. I2C2(PB10-SCL, PB11-SDA) is work well.
3. UART3(PC11-RX, PC10-TX) is work well too.
4. UART1(PB6-TX, PB7-RX) is work well too.
5. UART1(PB6-RX, PB7-TX) dose not work.
Is there any other way?
2018-11-16 02:54 AM
"5. UART1(PB6-RX, PB7-TX) dose not work."
Read the datasheet - there is no such mode in it! You can't set any pin to any function.
2018-11-18 04:42 PM
Hi Piranha
I know that default USART1 are PB6-TX, PB7-RX as the datasheet.
Our HW team has opposite designed the PIN.
Is it really impossible?
Thanks.
2018-11-18 04:53 PM
What is the complete/specific part number of the chip you are using? ST has a range of parts with assorted capabilities and dies.
https://www.st.com/resource/en/datasheet/cd00161566.pdf
The USART1 remapping to PB6/PB7 should be viable, but we're talking 10 year old parts, and I've moved on from them. The F1 family had peripheral level remapping, newer families have a richer pin muxing fabric which affords more/different opportunities.
>>Our HW team has opposite designed the PIN.
They swapped the TX and RX usage?
2018-11-18 05:02 PM
I'm using the STM32F103RBT7.
let me know if you have detail instructions or related doc to remapping.
Thanks.
2018-11-18 05:18 PM
The Data Sheet, Reference Manual, and SPL library source proved sufficient for me.
But per the docs, you're not going to be able to switch RX and TX functionality around, that is beyond the scope of remapping. PB6 is the OUTPUT, PB7 is the INPUT