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

13 REPLIES 13

@Ozone wrote:

While it might be possible to get Cube project working in Segger ES, .


Sure it's possible: what is generated is just standard C source code - there is nothing magic or special about it.

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.

> Sure it's possible: what is generated is just standard C source code - there is nothing magic or special about it.

The "downside" from a Cube user's pespective is no direct import of Cube projects, an thus the CubeMX tool.
Segger ES can import EWARM projects, Keil MDK projects and generic Eclipse projects, amongst more general options.
And of course this would require a Cube user (which is another term for a beginner) to create new projects in Cube including the graphical pin setup tool (*.ioc).
And to re-create reasonable project settings in Segger ES itself.
Which is not a problem for a more experienced developer, but many Cube users.

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.

Hi @Andrew Neil 

Your design has to ensure that it's safe.


understood thank you.