2025-07-17 1:38 AM
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
2025-07-17 2:00 AM
"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.
2025-07-17 2:16 AM
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.
2025-07-17 2:59 AM
> 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.
2025-07-17 3:11 AM
Hi @Ozone
> But this wouldn't be the first problem (bug) of this kind in Cube, far from it ...
yes i think the same too.
I try some test with external resistor and open-drain, but i have to talk with SDI-12 protocol and in push-pull seems to work better. Thank you.
Best.
Enrico.
2025-07-17 7:22 AM
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.