STM32L412C8 USART2 RX TX pin swap not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-05-26 5:37 AM
I am using the STM32L412C8 and I am having trouble with the USART2 RX/TX pin swapping. I enabled it in CubeMX but if I send data to the PA2 pin (originally TX but should be RX after the swap) I get nothing. If however I send my data to PA3(should be TX after the swap) data instantly comes in. Checking the CR2 register of the USART, the SWAP bit is set.
What am I doing wrong?
- Labels:
-
STM32L4 series
-
UART-USART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-05-27 10:56 AM
And what about a simple status-register-based polling loop?
You could also read out and post the content of the UART registers, and maybe also the relevant GPIO registers.
Have you observed the received waveform directly on the Rx pin, using oscilloscope or LA?
Can you disconnect the target device and loop back Tx to Rx?
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-05-27 2:06 PM
I will try it tommorow and I'll let you know.
I have connected a USB-to-Serial in parallel and I can read data correctly so the waveform seems to be OK.
I can't disconnect it as it's soldered on a PCB but I might be able to short the two pins together.
Thank you for your help either way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-05-28 1:04 AM
So an update:
A simple polling of RDR shows nothing received.
The USART registers are: CR1: 0xd , CR2: 0x8000, CR3:0
GPIOA MODER:0x6aa8a6a8 (so PA2, PA3 are 0x2)
GPIOA AFRL2=0x7,AFRL3=0x7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-05-28 1:26 AM
Also, trying to use LPUART1 instead as it can be mapped to the same pins and also swap TX/RX has the exact same problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-10-11 7:34 AM
Hi @KAsim​ ,
Have you solved this issue?
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-10-12 3:43 AM
Due to changes in the project, the whole PCB was redesigned, eliminating the need for pin swapping.
I never did manage to actually track down the problem though.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-10-12 7:15 AM
Thanks anyway for the info.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-31 12:47 AM
I have the same problem with an STM32F030RC. The UART has been configured with the Swap bit enabled (verified), but I get nothing on the new Tx line. Disabling the Swap bit allows data to be sent on the original Tx line. I'd like to know if anyone has got Tx/Rx swapping working?

- « Previous
-
- 1
- 2
- Next »