2019-02-19 04:54 AM
It seems that STM32CubeMX does not properly handle tx/rx swap when UART is set to half duplex mode.
Steps to reproduce
-start a project with a MCU with pin swappable uart, like STM32F030x
-enable UART in half duplex mode
-enable pinswapping
The incorrect behavior can be seen on CubeMX GUI as the wrong CPU pin is highlighted as well as in generated code where the GPIO config in xxxx_hal_msp.c is done for the TX pin instead of RX.
2019-02-21 05:20 AM
Hi @kha
According to the reference manual, in half duplex mode, the TX pin is a standard I/O in receive or in transmit. That's why only the TX pin is highlighted.
Regards,
Nesrine.
2019-02-21 05:55 AM
Then there is the 'SWAP' which exchanges the RX and TX pins, notably it will make halfduplex to use the pin normallyused for RX. I have confirmed this to be the case with hardware.
2019-02-21 05:57 AM
2019-02-21 08:30 AM
Hi @kha
As shown in the figure, in USART single wire half duplex mode:
So, SWAP will exchange the TX and TX pins .
Regards,
Nesrine.
2019-02-21 09:26 AM
Ok, you lost me this time...
You seem to ignore the fact that I have tested this on real hardware, if swap is enabled on halfduplex UART the physical pin will change.
The "halfduplex" mode connects the TX and RX lines internally on one UART to its TX line, now the swapping feature is on the IO pin side of this and thus will map the (combined) UART TX signal to the RX pin.
2019-02-22 12:40 AM
Hi @kha
Thank you for the feedback.
You are right, i was able to reproduce the issue and it will be fixed in the next CubeMX release.
Best Regards,
Nesrine.
2019-02-22 03:32 AM
Hi Nesrine,
Thank you for your efforts, this is a very corner case but it is good to have it patched up.
Best regards, Kari
2023-08-28 06:33 PM
This still seems to be broken in Stm32CubeIDE v1.13.1 (with included Stm32CubeMX v6.9.1).
Repro steps: