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

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
rimen05
Posts: 3
Joined: Wed Aug 09, 2023 7:30 am
Answers: 1

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

Post 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,
by rimen05 » Thu Aug 17, 2023 2:45 am
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,
Go to full post
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

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

Post by fpiSTM »

By default pins are configured with PULLUP:
https://github.com/stm32duino/Arduino_C ... #L136-L154
rimen05
Posts: 3
Joined: Wed Aug 09, 2023 7:30 am
Answers: 1

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

Post 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.
rimen05
Posts: 3
Joined: Wed Aug 09, 2023 7:30 am
Answers: 1

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

Post 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,
Post Reply

Return to “General discussion”