2023-11-25 05:54 PM - edited 2023-11-25 05:57 PM
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.
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.
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
Solved! Go to Solution.
2023-11-26 11:21 PM
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);
2023-11-25 06:58 PM
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.
2023-11-25 07:00 PM
That you for your help. how do you overcome this?
2023-11-25 10:54 PM - edited 2023-11-25 10:56 PM
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.
2023-11-26 08:05 AM
>>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.
2023-11-26 04:56 PM - last edited on 2023-11-27 10:29 AM by Amelie ACKERMANN
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.
2023-11-26 11:21 PM
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);