cancel
Showing results for 
Search instead for 
Did you mean: 

transmit and receive messages using usart?

avatar_ang
Associate

Hello
I want to create sort of application that transmit and receive messages between 2 STM32F407 DISC0 and echo the transmited and received messages in PC screen(sort of chatbox)
any hints how can I do it?
and is it easier using USART or SPI?

4 REPLIES 4
Andrew Neil
Super User

Of course, transmitting and receiving messages is exactly what UARTs are for!

You will need:

  1. One UART on each Disco board for the communication between boards;
  2. One UART for the communication between the Disco board and PC
    (one UART on each board of you want both of the boards to be connected to a PC)
 

Image1.png

 

PS:


@avatar_ang wrote:

and is it easier using USART or SPI?


That depends on how familiar you are with SPI...

Connecting to a PC is certainly easier via UART.

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.
Hal3
Associate III

The simplest PC side would use UART to USB adapter cables and either  two Terminal programs in the PC or one terminal program in each of two PCs.


@Hal3 wrote:

The simplest PC side would use UART to USB adapter cables 


Simpler still: the VCPs in the ST-Links on the Disco boards.

Except that @avatar_ang seems to be using STM32F407G-DISC1  - where the VCP is not connected.

 

@avatar_ang if you're specifically wanting to do UART comms with PCs, it would make a lot more sense to choose a different board which does have a working VCP.

eg, NUCLEO-F411RE if you want to keep in the F4 family ...

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.
Hal3
Associate III

If the Chat application will be ultimately on a custom board and requires one PC with one connection, connect the two processors with a 485 bus using uart to 485 transceivers and connect the PC with a 485 to USB adapter. That will minimize ground problems and easily expand to more processors.