Page 1 of 1

How to internally pullup TX line when using HardwareSerial + HalfDuplex?

Posted: Wed Aug 09, 2023 7:52 am
by rimen05
Dear all,

I am utilizing a board based on the Blue Pill board for my project, aiming to establish half-duplex communication with UART-controlled servo motors. To achieve this, I am leveraging the HardwareSerial API.

However, I've encountered an issue: while sending commands to the servos using HardwareSerial configured in full-duplex mode yields the expected responses, the servos do not respond as anticipated when I switch to half-duplex mode.

Upon investigation, I've noticed that upon entering half-duplex mode, the TX line of my UART port is no longer held HIGH; instead, it appears to transition to a high-impedance state when idle. Consequently, while the command is still being sent, the motors fail to respond due to their anticipation of the line being HIGH during idle periods.

My query is this: how can I ensure that the TX line of the half-duplex mode remains HIGH by default?

Best regards,

Re: How to internally pullup TX line when using HardwareSerial + HalfDuplex?

Posted: Wed Aug 09, 2023 9:06 am
by fpiSTM
By default pins are configured with PULLUP:
https://github.com/stm32duino/Arduino_C ... #L136-L154

Re: How to internally pullup TX line when using HardwareSerial + HalfDuplex?

Posted: Wed Aug 09, 2023 4:09 pm
by rimen05
Hello fpiSTM,

Thank you for your response.

I'm a bit puzzled as to why I'm observing different behaviors. When I configure UART in full-duplex mode, I see the following waveform in the scope:

https://drive.google.com/file/d/1b_o2JF ... drive_link

However, when I switch to half-duplex mode, the waveform changes to this:

https://drive.google.com/file/d/1AyQdgD ... drive_link

It's possible that during the initialization of half-duplex mode, the TX pin might be losing its pull-up, leading to this discrepancy.

Thank you for your assistance with this matter. Your insights are greatly appreciated!

Best regards.

Re: How to internally pullup TX line when using HardwareSerial + HalfDuplex?

Posted: Thu Aug 17, 2023 2:45 am
by rimen05
Hello,

I'm excited to let you know that I've fixed the issue I was having. It seems that you can't use an internal method to pull-up when using Half-Duplex communication. Someone in a discussion explained this well, and you can read about it here: Link to discussion.

Once I understood this, the solution was pretty simple. I added an external pull-up resistor.

After making this change, everything worked just as I expected.

Best regards,