Skip to main content
Associate II
August 22, 2025
Solved

nucleo_g474: mysterious bytes received on UART Rx

  • August 22, 2025
  • 6 replies
  • 1203 views

Hi Guys

I am doing a project and I notice that if I unplug the UART cable(FTDI) and then connect it again, there is a chance that there would be mysterious bytes received from RDR.

 

What is more interesting is that the mysterious bytes are actually the messages that was sent out to UART Tx.

 

During the testing, I am not using any UART serial monitoring tool like Putty or what's so ever, so there should not be any inputs to the UART Rx.  But it just happened, not often, but if I repeat disconnect and reconnect dozens of times, then something from UART Tx got into the UART Rx buffer.

 

I have confirmed that those mysterious bytes are read out from RDR.

 

Has any one know what's happening ? 

 

Thanks.

Best answer by TDK

But unplugging the USB doesn't disconnect the device from the STM32. The RX pin is still connected to whatever is on the adapter board, along with TX and GND.

As its power starts to drop, it is still trying to drive that pin but VDD isn't 3.3 V anymore. That's what you're seeing. Eventually, the chip powers off and the pin goes high impedance.

6 replies

TDK
Super User
August 22, 2025

Is RX floating? If so, nearby pins will influence it, such as TX.

If it's not floating, then there is probably another explanation. Code bug, misinterpretation, etc.

"If you feel a post has answered your question, please click ""Accept as Solution""."
pasuzwAuthor
Associate II
August 22, 2025

pasuzw_0-1755842144002.png

Blue is Rx and Yello is Tx.   There seems no pull up on Rx, so it drops when UART cable is disconnected.

Karl Yamashita
Principal
August 22, 2025

UART uses push-pull on the TX pins. So yeah, if you disconnect the USB to the FTDI, it can't pull the Rx pin to high.

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source
Ozone
Principal
August 22, 2025

You are probably talking about a Windows host here.
Consider that the host USB drivers are not perfect either. Far from it, actually.

Mike_ST
Technical Moderator
August 22, 2025

Hello,

The minimum thing to do is to activate internal pull-up resistor on the Rx line of the STM32, to avoid it floating in case nothing is connected.

pasuzwAuthor
Associate II
August 26, 2025

Hi Mike

 

I tried to use the internal pull up and got below behaviour. It seems still a voltage drop for a short period of time when I disconnect uart cable.  Is it normal ?   And I can see vertical noise that is synchronized with Tx timing,  which is probably due to coupling ?

UART_RX_WITH_INTERNAL_PULL_UP.jpg

Mike_ST
Technical Moderator
August 26, 2025

Hello,

>> I tried to use the internal pull up and got below behavior. It seems still a voltage drop for a short period of time when I disconnect UART cable. Is it normal ?

Can't tell.

I have never analyzed plug/unplug events on a serial line.

I'm not sure what I'm seeing on the scope, what kind of event it is, at what time stamp, and where the probe is connected.

>> I disconnect UART cable

Is it a RX+GND disconnection, or is it just the RX wire ?

>> And I can see vertical noise that is synchronized with Tx timing, which is probably due to coupling ?

Probably.

pasuzwAuthor
Associate II
August 26, 2025

Is it a RX+GND disconnection, or is it just the RX wire ?

-> I disconnect the usb port of FTDI C232 HD cable on the computer side.

 

TDK
Super User
August 26, 2025

Something isn't right here. If you disconnect RX, and the internal pullup is enabled, the level will not drop.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Bob S
Super User
August 26, 2025

What connector does the USB-to-UART cable have on the STM32 end?  Is it one with the tip.ring/sleeve audio style connector (FTDI TTL-232R or TTL-234X cables)?  If so, as you unplug that connector it can temporarily short the RX to GND.

EDIT: Like this:

BobS_0-1756239257996.png

 

pasuzwAuthor
Associate II
August 26, 2025

I am using FTDI C232HD, and it has 3 seperate wires to connect to STM32 pins.   I disconnect UART by unplug the USB connecter on the computer side.