Skip to main content
Associate II
July 17, 2025
Solved

Stm32u083x lpuart3 half-duplex only open-drain on CubeMX

  • July 17, 2025
  • 4 replies
  • 646 views

Hi

i working on stm32u083rctx with U0 fw package v1.3.0 and CubeMX 6.15. On CubeMX i initialized lpuart3 in half-duplex mode on PC4 pin. I notice that PC4 is only possible to set as open-drain. I want to select PC4 as push-pull. In function:

void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)

if i change PC4 init line form:

GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;

 to:

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

my code is working. I don't known if it is correct configure push-pull when lpuart3 is in half-duplex mode. So i ask if it's safe to do that. Thank you.

Best regards.

Enrico

Best answer by Andrew Neil

@enmarke wrote:

I don't known if it is correct configure push-pull when lpuart3 is in half-duplex mode.


"Half-duplex" means that a single line is used for comms in both directions (one at a time).

Therefore  the same pin gets used as both an input and an output.

This needs to be managed carefully so that you don't end up with two outputs both trying to drive the line at the same time!

Configuring the output as Open-Drain provides a safe way to do that - as @Ozone described.

Another option would be to make the default state input - so it's up to the user to only change it to output when safe to do so.

 


@enmarke wrote:

So i ask if it's safe to do that. Thank you.


Your design has to ensure that it's safe.

4 replies

Ozone
Principal
July 17, 2025

"Open-drain" vs. "push-pull" is solely an electrical issue, and unrelated to half-/full duplex or protcol settings.

Open-drain would require an external load resistor (open-collector for BJTs).
Such a configuration is e.g. specified for the I2C bus.

I always used PP for UART pins.

enmarkeAuthor
Associate II
July 17, 2025

Hi @Ozone

thank you for your response that clarify the electrical issue. Why in CubeMX is not possible to select gpio mode as push-pull? In the past i have worked with stm32wle5x and by CubeMX was possible to configure half-duplex uart gpio as push-pull.

Best regards.

Enrico.

Ozone
Principal
July 17, 2025

> Why in CubeMX is not possible to select gpio mode as push-pull?

I don't use CubeMX, so I can't really answer this question.
But this wouldn't be the first problem (bug) of this kind in Cube, far from it ...

On a related note, you could most probably run a UART with GPIOs configured in OD mode - if you add an external pull-up resistor. 

The advantage of an OD configuration is that each bus participant can actively "drive" specific bus lines. "Drive" means pull the signal level to low in this case. This happens e.g. during the 9.th clock cycle during an I2C transmission, when the master turns the SDA line driver off while still driving SCK, and the slave device drives SDA (to low) for the ACK bit. That would not work with push-pull driver configuration.

Ghofrane GSOURI
Technical Moderator
July 17, 2025

Hello @enmarke 

I'm currently investigating this issue.

I will get back to you asap.

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.
Ghofrane GSOURI
Technical Moderator
July 18, 2025

Hello @enmarke @Ozone 

Your request has been escalated to the development team.

Internal ticket number :214405 

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.
enmarkeAuthor
Associate II
July 21, 2025

Hi @Ghofrane GSOURI 

thank you.

Best regards.

Enrico

Andrew Neil
Andrew NeilBest answer
Super User
July 21, 2025

@enmarke wrote:

I don't known if it is correct configure push-pull when lpuart3 is in half-duplex mode.


"Half-duplex" means that a single line is used for comms in both directions (one at a time).

Therefore  the same pin gets used as both an input and an output.

This needs to be managed carefully so that you don't end up with two outputs both trying to drive the line at the same time!

Configuring the output as Open-Drain provides a safe way to do that - as @Ozone described.

Another option would be to make the default state input - so it's up to the user to only change it to output when safe to do so.

 


@enmarke wrote:

So i ask if it's safe to do that. Thank you.


Your design has to ensure that it's safe.

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.
enmarkeAuthor
Associate II
July 21, 2025

Hi @Andrew Neil 

Your design has to ensure that it's safe.


understood thank you.