cancel
Showing results for 
Search instead for 
Did you mean: 

Sending UART messages between two boards

Jack_DB
Associate

Good morning,

I need to connect two h7a3zi-q board via uart (only one way required), but by only connecting tx1->rx2 the programs run but I get empty strings, and by also connecting the grounds of the two boards the tx program gives HardFault. I'm sure of the content of the msgs as I also send via uart3 to my pc and I have no problems. 

Any tips?

Thx

8 REPLIES 8
mƎALLEm
ST Employee

Hello,

You can refer to any of the example provided in CubeH7:

https://github.com/STMicroelectronics/STM32CubeH7/tree/master/Projects/NUCLEO-H7A3ZI-Q/Examples/UART

All the examples are using two board connected over UART to transmit messages:

mALLEm_0-1763126579505.png

 

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.
KnarfB
Super User

Showing your code tx/rx loop might help here. Make sure that the rx is always receiving, and you may start by receiving single bytes in an endless polling loop.

hth

KnarfB

Jack_DB
Associate

Just to make sure, you confirm that connecting the grounds is required? my working theory is that the rx reads only empty strings as it doesn't have a reference value to distinguish 0 bit to 1 bit, but it doesn't explain why the program gives error if the gnds are connected  


@Jack_DB wrote:

Just to make sure, you confirm that connecting the grounds is required? 


It's mandatory.

Refer to the readme file of one of the examples provided above:

mALLEm_0-1763128471582.png

That's not only related to USART but to the most communication interfaces between boards except the differential communication protocols (like CAN for example).

 

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.
Saket_Om
ST Employee

Hello @Jack_DB 

Please refer to the article below to debug your Hard fault:

How to debug a HardFault on an Arm® Cortex®-M STM3... - STMicroelectronics Community

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.
Saket_Om
TDK
Super User

Connecting GND shouldn't cause a hard fault. If there is a voltage difference between the GND of the two boards, why? How are they connected? USB gnd is generally tied to earth ground, or isolated. Shouldn't be a problem there.

If you feel a post has answered your question, please click "Accept as Solution".

>>Just to make sure, you confirm that connecting the grounds is required? 

Yes, how the electrons flow...

Now you might implicitly achieve this via the USB connector to a common computer, but you are just creating a longer and potentially more difficult path to complete the circuit.

Solve the Hard Fault, it's a gross error and suggest other latent issue in your code. Perhaps getting a lot of interrupts and you incrementing through the end of a buffer. ie buffer[i++] = char, where 'i' is unbounded.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Super User

As always, don't try to do both ends of the link at once !

Get each part working independently, tested against a known-good reference, before bringing them together.

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.