Skip to main content
Associate II
November 26, 2023
Solved

Using to two stm32H7A3ZI-Q to transmit and receive

  • November 26, 2023
  • 3 replies
  • 1998 views

I am using two stm32H7A3ZI-Q board to transmit and receive data (which is a double). 

I am using HAL_UART_Tramsit and HAL_UART_Receive_IT to send and receive the data. 

When i connect Tx to Rx on the same board, it sends and receives data fine. The image below, is showing that both boards are working when Tx is connected to Rx on the same board

CircuitFreak_0-1700963017623.png

When connecting the Tx of board 1 to Rx of board 2 and Tx of board 2 to Rx of board 1 it stops working and it receives nan (Not a Number). The image below is showing this. 

CircuitFreak_1-1700963214673.png

I dont think it has anything to do with my calculations because when i send a integer is still happens. 

Thank you for your help. 

 This is how i am sending and receive data

CircuitFreak_0-1700963822919.png

 

 

This topic has been closed for replies.
Best answer by CircuitFreak

Thanks for the Help!!

 

I have find a solution. The issue was the it was receiving while the transmission was happening. Like @TDK  said. Thank you. 

I solve this by using the function below, and a while loop.

void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart);
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart);

 

3 replies

TDK
Super User
November 26, 2023

You need to be receiving while the transmission happens. You're sending first, then trying to receive.

And you need to wait for the reception to complete before you parse the data. You're not waiting at all.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Associate II
November 26, 2023

That you for your help. how do you overcome this? 

Tesla DeLorean
Guru
November 26, 2023

>>how do you overcome this? 

Initiate the background reception interrupt first, so it's ready to receive as soon as the data appears on the wire.

Consider buffering, and using the IT versions of the transmission.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
STTwo-32
Technical Moderator
November 26, 2023

Hello @CircuitFreak and welcome to the ST Community :smiling_face_with_smiling_eyes:.

You Can refer to this example where, Board 1is transmitting then receiving ans Board 2 is receiving then transmitting.

PS: read carefully the Readme file to understand how it works.

Best Regards.

STTwo-32.

Piranha
Principal III
November 27, 2023

That example sends and receives a single constant array with the same size. It does it in a half-duplex style and doesn't even do a simultaneous transmission and reception. It does it just once with a polling and therefore cannot do anything else in parallel. And even this scenario will fail, if a single byte is lost because of noise.

It's so far from a real world needs, that it's useless. Can anyone at the HAL team grasp that reality?

Edited by moderation to adhere to community guidelines.

CircuitFreakAuthorBest answer
Associate II
November 27, 2023

Thanks for the Help!!

 

I have find a solution. The issue was the it was receiving while the transmission was happening. Like @TDK  said. Thank you. 

I solve this by using the function below, and a while loop.

void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart);
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart);