cancel
Showing results for 
Search instead for 
Did you mean: 

Using DMA on UART for Rx (circular) AND Tx (normal) at the same time.

snigg
Associate III

Hi, I am facing the problem of using DMA for a CPU load reduced UART communication for RX and TX. I think it is likely that I don't understand the DMA correctly. So before pasing Code and messing things up, I explain my intentions.

Issue:

I am able to setup and use DMA for RX in circular mode. I am also able to use DMA for TX in normal mode. BUT as soon as I use DMA for TX my RX DMA stream seems to fail. Rx uses DMA1_Stream0 (Channel_4) and Tx uses DMA1_Stream7 (Channel_4). So is there a Problem. Why does it silently fail. What is my error in logic? What are the restrictions on Using multiple DMA channels. The documentation fails to give me more information (as so many times). So I try this forum approach.

I have read all I could find in this forum regarding using DMA and UART. But so far none seem to have answered the issue of Tx stream silently killing circular Rx stream.

5 REPLIES 5

Which STM32?

> my RX DMA stream seems to fail

What do you mean by this, exactly? What are the symptoms and how are they different from the expectations?

The Rx and Tx in UART are to large extent independent (except that they share a common baudrate divider), and so are their DMA channels.

Do you observe the UART registers during runtime using a debugger? Then don't.

JW

snigg
Associate III

I try to clarify:

I would like to start the Rx DMA just once and then never have to touch it. I only want to periodically check the buffer (and DMA1_Stream0->NDTR) for new arrived data.

The Tx DMA should then be started as needed to send a data frame. Several time almost completely independent of the Rx.

I have a running system with the circular Rx DMA and as the commands (LED on/off) works it is receiving data. But as soon as I once startet a Tx DMA Stream commands no longer are received.

So I need to know if my expectations are wrong or (more likely) my code. While there might be the slight chance that it is a known HAL issue (STM32F7 V1.14.00).

HAL could break things, but the HW can simultaneously transmit and receive, and uses different DMA resources to achieve that.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
snigg
Associate III

Ok, thanks for that clear statement. So I can concentrate the code.

Is there a way to mark this as "solved"?

Jack Peacock_2
Senior III

If your DMA fails "silently" are you checking error status, both the error flag on DMA channel and receive errors on the USART? Errors will stop the DMA. Enable the error flag interrupt on DMA in case you have some kind of bus fault.

Jack Peacock