cancel
Showing results for 
Search instead for 
Did you mean: 

Using to two stm32H7A3ZI-Q to transmit and receive

CircuitFreak
Associate III

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
CircuitFreak
Associate III

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);

 

View solution in original post

6 REPLIES 6
TDK
Guru

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".

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

STTwo-32
ST Employee

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.

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.

>>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 Venmo
Up vote any posts that you find helpful, it shows what's working..

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.

CircuitFreak
Associate III

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);