cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 NUCLEO-F429ZI Unable to Communicate with HMI via RS232/RS485

QuangIoT
Associate II

 

I am facing an issue connecting the STM32F4 NUCLEO-F429ZI board to an HMI screen that uses RS232 and RS485 communication standards. The HMI can communicate successfully with my computer, but the STM32 board cannot communicate with the computer except through UART3 and using a direct cable connection. This prevents me from establishing communication between the STM32 board and the HMI screen.

Could you please help me identify what might be causing this issue and how I can resolve it?

Thank you!

16 REPLIES 16

@QuangIoT wrote:

 

I have tested the STM32 separately with the computer, but the STM32 does not receive the messages sent from the computer.

So, as @mƎALLEm says, you need to address that first - before adding the complications of the "HMI display"

 


@QuangIoT wrote:
I have tried debugging both the hardware and software.

So what, exactly, have you done? What have you observed? What have you learned about what's going on?

 


@QuangIoT wrote:
Communication Interfaces
RS232: Supports serial communication
RS485: For industrial environments requiring differential signaling
TTL UART: 3.3V level UART communication
Baud Rate: Configurable, typically 9600 to 115200 bps

So 3 different options for the connection - are you sure you're using the correct one, and the configuration is correct?


@QuangIoT wrote:

 I still have the transmission cable plugged in.


You need to provide what you are using as cable? could you please share an image please? the connection between the Nucleo and the computer?

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.
QuangIoT
Associate II

Tôi đang sử dụng cáp này và tôi đảm bảo tiêu chuẩn truyền thông chính xác

You've already said the following:


@QuangIoT wrote:

I'm using USART 3 with my computer via STLINK and communication is normal, but if I switch to using USART2 (PD5 is TX and PD6 is RX) and of course the code will also change from uart3 to uart2 but it won't transmit. receive. 


If you are using USART2 with STLINK Virtual Comport, that will not going to work as that UART is not connected to the STLINK VIRTUAL comport as shown in the schematics I shared before.

So you need to use an external USB-to-UART module that will be connected to PD5 and PD6.

You need also to probe Tx and Rx with a logic analyzer or an oscilloscope to check where it goes wrong.

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.

@QuangIoT wrote:

I'm using this cable and i ensure correct communication standard


That's the USB cable which connects the ST-Link to your computer.

That's what carries the debug/programming connection, and the VCP (Virtual COM Port)

As pointed out by @mƎALLEm, that VCP is connected to USART3 (PD8 & PD9) on the STM32F4 microcontroller.

So, if you want to use USART3 to communicate with any external device, you are first going to have to disconnect it from the ST-Link VCP - that's what the SB5 & SB6 links are for:

AndrewNeil_0-1732614281721.png

AndrewNeil_1-1732614678241.png

https://www.st.com/resource/en/user_manual/um1974-stm32-nucleo144-boards-mb1137-stmicroelectronics.pdf#page=1

AndrewNeil_2-1732614918993.png

 

 

Of course, once you've disconnected them from the ST-Link, then you will no longer be able to communicate over the VCP - you will need a separate USB-to-UART converter.

Similarly, if you use any other UART connection than PD8 & PD9, that will not be connected to the ST-Link and, therefore, will not be accessible via the ST-Link's VCP -  so you will, again, need a separate USB-to-UART converter.

 

QuangIoT
Associate II

i transmitted/received data from stm32 to my computer however, i transmitted "123" but stm32 received "67 B3 06". I used uart 2(PD5 Tx, PA3 Rx)

 

 

 

 

 

 

 

 

 

 

 

 

 


@QuangIoT wrote:

i transmitted "123" but stm32 received "67 B3 06".


How are you observing what the STM32 received?

Receiving "junk" characters is usually due to incorrect baud rate:

https://learn.sparkfun.com/tutorials/serial-communication/all#:~:text=If%20all%20the%20receiving%20device%20sees%20on%20its%20receive%20line%20is%20garbage%2C%20check%20to%20make%20sure%20the%20baud%20rates%20match%20up

Is data sent from the STM32 to the PC similarly corrupted?

Have you used an oscilloscope or logic analyser to see what's actually happening on the wire?

 


@QuangIoT wrote:

I used uart 2(PD5 Tx, PA3 Rx)


With a separate USB-to-UART adapter, then?