2025-02-12 09:29 PM
Hi,
I am using STM32H753ZI nucleo board, developing with Keil IDE. I am using UART RX and TX DMA. I want to check if there is a possibility of corruption of UART data while transmitting with DMA Tx.
The sending device will send 8-byte defined command to STM32H753ZI and then STM after performing the required operation will send response in a 8-byte defined format.
My system works very well, but sometimes the UART data which is transmitted back to sending device in response to some specific command is seen to be corrupt or any random data other than defined protocol or packet message data
Also, it is seen that the data is sent to sending device without any command which the code never does (that data are mostly 0 0 0 0 0 0 0 0 all 0's of 8 byte).
I am doubting something has gone bad on USB to UART TTL module or USB hub or something in hardware. But just wanted to be sure if there is nothing missed from firmware side for DMA Tx with respect to corruption since DMA uses memory to store data.
Anything to be taken care with respect to memory assignment (stack and heap) in startup file for this?
2025-02-12 09:41 PM
How often are you receiving data? Are you possibly receiving data while transmitting?
Show relevant code
2025-02-12 11:58 PM
How often are you receiving data?
The data is not receiving very often. It is based on operations to perform. It is an 8-byte command based on which certain operations are performed and then response is sent back in an 8-byte format.
In an operation, if you want to see the timing difference between the command sent from sending device:
1 sec, 2.5 min, 2 min 20 sec, 5 min 20 sec, 2 min, 1 sec,14 sec,3 sec 2.5 min etc
Are you possibly receiving data while transmitting?
No, I don't think. But let me know if any check required to be added in code. Attaching UART code file.
2025-02-13 06:03 AM - edited 2025-02-13 06:04 AM
> My system works very well, but sometimes the UART data which is transmitted back to sending device in response to some specific command is seen to be corrupt or any random data other than defined protocol or packet message data
Almost certainly this is a code bug, not a hardware bug.
Is the DMA buffer valid during the transfer? It should be in global memory, not on the stack.
Edit: show your calls to sendUart1Data and surrounding context. That's likely where the bug is.