cancel
Showing results for 
Search instead for 
Did you mean: 

How DMA Transmit works ?

majd-ghadab
Associate III
Posted on May 06, 2018 at 19:01

Hallo everyone i have a question..

as i know the DMA receives Data und when it reaches the Bytes the i have determined it makes interrupt so this is usefull because the cpu doesn't wait the UART slow connection to finish.

but the DMA Transmit works I have tried to read so many sources in Internt and couldn't find out.

do the CPU as i think put the data in the DMA when it reaches the DMA send instruction and then continue to the second instruction without waiting the receiving Terminal to finish and let the DMA controller do the Job.. or how

thanks

5 REPLIES 5
Posted on May 06, 2018 at 22:59

The DMA feeds the USART a byte at a time as it requests them.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
T J
Lead
Posted on May 07, 2018 at 02:38

the DMA is a simple Hardware block.

it has a start position, a length, a type, Circular or Normal, and an input that says NEXT.

the Uart has a 2 byte Fifo, or commonly referred to as a 'double buffered Uart', this is to reduce the interrupt latency.

during transmit,

after a byte actually leaves the PIN, the TXE flag goes high, triggering the NEXT byte function from the DMA.

the next byte is shoved into the TX stream and the DMA waits for the NEXT high.

Posted on May 07, 2018 at 08:10

Hallo thanks for explantion but for example when i use this instruction:

HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)

and sends 10 bytes then the CPU will hold on this instruction until it sends th 10 bytes or it sends 2 bytes and the others in memory for the dma controller to send them without the need of the main CPU or it waits because if it waits to send the 10 bytes what is the point of DMA transmition !

Amel NASRI
ST Employee
Posted on May 07, 2018 at 17:02

Hi

Ghadab.Majd

‌,

To understand how the DMA works and how to use it efficiently, please have a look to

http://www.st.com/content/ccc/resource/technical/document/application_note/27/46/7c/ea/2d/91/40/a9/DM00046pdf/files/DM00046pdf/jcr:content/translations/en.DM00046pdf

:Using the STM32F2, STM32F4 and STM32F7 Series DMA controller.

HAL_UART_Transmit_DMA is used to start data processing (transmission) in this case.

Then the processing status may be followed based on the callbacks (for errors or completion).

-Amel

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.

Posted on May 07, 2018 at 17:37

If you have doubts review the library source code, it is provided to allow you to do so.

As best I can tell it sets up the DMA transfer, and leaves. You can catch the completion in a call-back.

If the the USART isn't ready to accept bytes zero may be initially transferred.

DMA simple describes a buffer, it automates the transfer to the peripheral, and it services the peripheral as it requests more data.

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