Skip to main content
Marco Bertoncin
Associate II
December 14, 2020
Solved

Is it possible to remap UART pin shown in STM32 IDE with any pin?

  • December 14, 2020
  • 6 replies
  • 3735 views

The STM32 IDE project shows some "default" mapping to use in the U[S]ART1-6. For example, UART1 has PA9(TX) and PA10(RX). Are these GPIO pins fixed? Can any be used? Is there any restriction on which pin can be used with which UART block?

In particular, we have an STM32F407.

Thanks,

Marco

This topic has been closed for replies.
Best answer by Tesla DeLorean

If you don't want to play pin mapping bingo several months into the project it is probably better to do the due diligence up front, and get the pins assigned to all critical interfaces you're going to need, and then use the available slack GPIO for LEDs, buttons, or things that can be readily reassigned.

6 replies

Tesla DeLorean
Guru
December 14, 2020

There are a handful of usuable pins.

There is a pin matrix in the part's Data Sheet, I suggest using that as a guide.​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Ozone
Principal
December 14, 2020

> There is a pin matrix in the part's Data Sheet, I suggest using that as a guide.

IMHO the first source to go to.

This is where Cube IDE pulls it from. And adds some Copy&Paste errors occasionally.

Marco Bertoncin
Associate II
December 14, 2020

Thanks all! The issue I have is how do I change what PIN is mapped to what UART using the IDE. I really would like to keep the code as close as possible to that which is generated with the "Generate Code" option. If all pin mapping need redoing manually, every time something changes, those changes will have to be ported. No a big deal, but as the project grows and different people put their hands on it, it becomes messy...

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
December 14, 2020

If you don't want to play pin mapping bingo several months into the project it is probably better to do the due diligence up front, and get the pins assigned to all critical interfaces you're going to need, and then use the available slack GPIO for LEDs, buttons, or things that can be readily reassigned.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Marco Bertoncin
Associate II
December 14, 2020

Thanks. That is always a good idea, unless it has already been done otherwise by someone else ... I guess the question now is: can you change the "default" the STM32IDE comes up with easily? For example, if you enable UART1 you get automatically PA9 and PA10. How do you select PB6 for UART1(TX), which is possible setting ALT7 to GPIO pin PB6 ... ?

Thanks!!

Marco

Marco Bertoncin
Associate II
December 14, 2020

OK, I do apologize for wasting your time guys .. .I found it. You do not have the choice in the pane where you configure the UART, but you can do that by previously re-assigning the GPIO function in the PIN definition (where you have all the pins shown around the chip). By doing that, now you see the "right" pin appearing when you select UART1.

Thanks all!

Marco