cancel
Showing results for 
Search instead for 
Did you mean: 

Continuous DMA from UART

ST User
Associate III

Hello,

This is for the STM32H7, but may be applicable to other STM32 chips.

Is there a way to do a continuous DMA stream from a UART without requiring an expected size?

I would like to be able to set up a receive buffer with DMA in circular mode, and just say "give me infinite data" and have it continuously write data to the circular buffer. I'll handle the reading and parsing on my own as the data is written.

Is this possible to configure the DMA to do?

Thank you.

3 REPLIES 3
TDK
Guru

Yes. Start it in circular mode. It writes continuously as data comes in, without CPU intervention. Poll the NDTR register to find the current location.

If you feel a post has answered your question, please click "Accept as Solution".
berendi
Principal

Yes. On the H7, where there are a couple of different DMA controllers, use the "normal" DMA1 or DMA2, not BDMA nor MDMA. The memory buffer should be allocated in AXI SRAM when processed by the M7 core, or in AHB SRAM{1,2,3} when processed by the M4 core.

  • Pick a free DMA stream on DMA1 or DMA2.
  • Ensure that clocks for DMA, UART, and GPIO are enabled in RCC.
  • Set the request source for the selected DMA channel in DMAMUX1.
  • DMA stream peripheral address (PAR) is the address of the UART input data register, e.g. &USART1->RDR.
  • Memory address (M0AR) is the address of the circular buffer.
  • NDTR is the size of the buffer.
  • clear DMA interrupt flags (LISR/HISR).
  • set MINC and EN in the DMA stream control register (CR).
  • Configure the UART for the transfer mode, baudrate etc (FIFO is not necessary), and enable DMAR in CR3.

ST User
Associate III

Thank you: I had it configured this way, but was missing the first data set after the buffer was wrapping. It turns out I had a bug in my cache invalidation and it all works now!