Skip to main content
Visitor II
Nov 8, 2026 7:08 AM UTC
Question

swap RX TX of USART

Unfortunately, the RX and TX connections are swapped on the PCB.

I noticed that STM32CubeMX provides an option to swap the pins (see the attached screenshot).

I enabled this option, but it doesn't seem to have resolved the issue.

Is there any additional configuration or procedure required for this to work?

The MCU part number is STM32N657X0H3Q.

 

5 replies

MM..1
Super User
Nov 8, 2026 10:15 AM UTC

On nomal situation this is only required for swap working iface, but first must be working : meet clock and speed requirments and on N6 maybe next conditions.

Pavel A.
Nov 8, 2026 10:34 PM UTC

Should work.  Check the generated code: does it indeed set the register bit?

TDK
Nov 9, 2026 3:02 AM UTC

The option you highlighted swaps the pins. If that didn’t fix it, that wasn’t the (only) problem. Keep looking. Bad soldering, bad wiring, wrong pins, code not running. Lots of possibilities. Debug your code, step through.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Andrew Neil
Super User
Nov 9, 2026 8:13 AM UTC

If that didn’t fix it, that wasn’t the (only) problem. 

Absolutely!

 

Debug your code

​@Omerza also debug your hardware!

  • With an oscilloscope directly at the STM32 pins, what do you see ?
  • Can you toggle the TX pin just as a plain GPIO output ?
  • Can you read the RX pin just as a plain GPIO input ?

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Ghofrane GSOURI
ST Technical Moderator
Nov 9, 2026 8:10 AM UTC

Hello ​@Omerza 

I checked the code generated by STM32CubeMX 6.18.1 with the TX/RX swap option enabled. For USART2, CubeMX generates the following configuration

According to RM0486, this enables the SWAP bit in USART_CR2, exchanging the TX and RX pin functions . No additional pin-remapping step should be required.

As mentioned by ​@Andrew Neil , inspect USARTx->CR2 in the debugger and verify that SWAP, bit 15, is set.

THX

Ghofrane

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.