Change the Alternate functions default pin for USART1 on STM32F103
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-13 4: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-13 5: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.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-13 5: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.
​
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-13 5: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();
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-16 2: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-18 4:42 PM
Hi Piranha
​
I know that default USART1 are PB6-TX, PB​7-RX as the datasheet.
Our HW team has opposite designed the PIN.
Is it really impossible?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-18 4: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?
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-18 5:02 PM
I'm using the STM32F103RBT7.
let me know if you have detail instructions or related doc to remapping.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-18 5: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
Up vote any posts that you find helpful, it shows what's working..
