cancel
Showing results for 
Search instead for 
Did you mean: 

Stm32u083x lpuart3 half-duplex only open-drain on CubeMX

enmarke
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions
Andrew Neil
Super User

@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.

View solution in original post

13 REPLIES 13
Ozone
Principal

"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.

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.

> 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.

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.

Ghofrane GSOURI
ST Employee

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.

It looks like it is really a CubeMX issue, so you can use your "manual" workaround until it is fixed.

But to your other question ...
First, my company doesn't use STM32 devices in commercial projects. And even if we did, a vendor-specific toolchain for each Cortex M device is out of question. All our Cortex M devices are covered by IAR Workbench as toolchain.

Second, I use Segger Embedded Studio for private project, which is free for this purpose.
While it might be possible to get Cube project working in Segger ES, this is no option for me. I dislike the structure and design of the Cube/HAL code, and the myriad of bugs.
My projects are based on either "legacy" SPL code (the Cube/HAL predecessor), or bare-metal.

Ghofrane GSOURI
ST Employee

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.

Hi @Ghofrane GSOURI 

thank you.

Best regards.

Enrico

Hi @Ozone 

than you for explanation.

Best regards.

Enrico