Skip to main content
PRedd.5
Associate II
Oct 15, 2019 7:47 PM UTC
Solved

How is IT different from DMA at a hardware level ?

In DMA mode, the DMA block does copying. In normal mode the controller does the copying. So which block does copy in interrupt mode?

This topic has been closed for replies.
PRedd.5
PRedd.5Best answer
Associate II
Oct 16, 2019 2:05 AM UTC

It becomes much clearer once you look up the implementation of :

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

HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)

both of them can do arbitrary size transfers.

Reading the TRM. RM0316 : page 885 Sec 29.2 :

"Received/transmitted bytes are buffered in reserved SRAM using centralized DMA"

They are basically the same operation using different channels and modes of DMA. If all you care is to perform UART input/output without the processing unit getting involved, either mode (IT or DMA) will do fine.

The use of DMA peripheral mode is to allow peripheral to peripheral transfer and peripheral triggered data transfer without invoking the processing unit.

7 replies

waclawek.jan
Super User
Oct 15, 2019 7:49 PM UTC

The controller.

JW

Tesla DeLorean
Guru
Oct 15, 2019 10:11 PM UTC

..under interrupt/callback context. Not burning cycles in polling loop, but interrupt entry/exit does have cost.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
PRedd.5
PRedd.5Author
Associate II
Oct 15, 2019 10:19 PM UTC

So the bus controller is the one doing the transfers instead of DMA. If the controller can do full size transfers , why is DMA used at all ?

When would you choose DMA over controller interrupt ?

PRedd.5
PRedd.5AuthorBest answer
Associate II
Oct 16, 2019 2:05 AM UTC

It becomes much clearer once you look up the implementation of :

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

HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)

both of them can do arbitrary size transfers.

Reading the TRM. RM0316 : page 885 Sec 29.2 :

"Received/transmitted bytes are buffered in reserved SRAM using centralized DMA"

They are basically the same operation using different channels and modes of DMA. If all you care is to perform UART input/output without the processing unit getting involved, either mode (IT or DMA) will do fine.

The use of DMA peripheral mode is to allow peripheral to peripheral transfer and peripheral triggered data transfer without invoking the processing unit.

Piranha
Principal III
Oct 16, 2019 10:20 AM UTC

> They are basically the same operation using different channels and modes of DMA. If all you care is to perform UART input/output without the processing unit getting involved, either mode (IT or DMA) will do fine.

No, you are wrong. Polling and interrupt modes are both done by CPU. This is the line where in interrupt mode CPU reads a byte from Tx buffer and writes it to peripherals Tx register:

https://github.com/STMicroelectronics/STM32CubeF3/blob/e684e8712c42ad70d801adf73ba3b509ed04a7ff/Drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_uart.c#L2678

> The computer architecture they taught 12 years ago is far behind modern DMA and bus controller implementations.

The original IBM PC in year 1981 had Intel 8237 DMA controller working on the same principles...