cancel
Showing results for 
Search instead for 
Did you mean: 

UART DMA transmit and receive along with IDLE line detection

ADani
Associate III

Hello,

I'm trying to implement a UART DMA data transfer in STM32F429. I face the following problem.

I'm using custom-made Python to receive and transmit data over the serial port.

I am sending an unknown number of bytes from my computer to MCU.

So, I'm using IDLE line interrupt to check if the packet is transferred.

My requirement is once I receive the packet I have to perform some operations on it and send a response back to the computer.

Case 1: When the DMA transfer is working

In the UART interrupt, I do the following

1. Check for idle interrupt for UART5

2. Stop the DMA

3. Transfer the received bytes back to the computer (basically it is an echo example)

4. Start the DMA to receive bytes

Case 2: When the DMA transfer is not working

Inside the interrupt, I do the following

1. Check for idle interrupt

2. Stop the DMA

3. Check if it is a proper command from the PC

4. Set a variable to which is accessed by the main loop to perform a few tasks

5. Start the DMA to receive bytes

In the main loop, I perform a CRC check, do some manipulations, and transfer bytes via DMA. I debugged the variable which holds the response packet and it is proper.

Actually, I send 8 bytes as a response to the PC.

Observation:-

The variable (uint8_t response_packet[30]) which holds the response packet is an 8bit array with 30 elements.

I use only the first 8 elements (for now) since my test response is 8 bytes.

When I use the HAL_UART_Transmit_DMA(&huart5,response_packet,8) the data received in the PC is wrong. The First 5 bytes are correct the last three bytes are wrong.

When I use HAL_UART_Transmit_DMA(&huart5,response_packet,15) the first 8 bytes received in the PC are correct and the other values are junk.

At the end of the transfer, I do get an IDLE interrupt.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

I'm pretty sure the response packet generated by the main loop is correct. I guess it is the IDLE line detection that is causing the issue.

Does anyone have such experience while working with UART DMA? I would like to have some suggestions on how to encounter this issue.

Please let me know if more information is required.

Thank you.

0 REPLIES 0