I am trying to connect STM32G070 microcontroller with Quectel BC660K-GL via UART in DMA mode, using HAL libraries. There are two libraries both defining DMA communication functions (stm32g0xx_hal_uart.h
and stm32g0xx_hal_dma.h
). I am using Description of STM32G0 HAL and low-layer drivers manual. According to the manual _hal_dma.h
defines Interrupt mode IO operation (page 215.), while _hal_uart.h
provides, according to the description given in the library, Non-Blocking mode API's with DMA (lines 1054-1059). Hence I'm using DMA in order to offload CPU, which library would be preferred?
Asked
Active
Viewed 158 times
0

Nemanja
- 13
- 1
- 5
-
"*According to the manual _hal_dma.h defines Polling IO operation*" -- No, you are misunderstanding the manual. Apparently you are incorrectly conflating "interrupt mode" and "*Polling IO*". (Study https://stackoverflow.com/questions/25318145/dma-vs-interrupt-driven-i-o/38165400#38165400) That manual excerpt describes using DMA transfers with DMA interrupts, and no "*polling*" is involved. "*Hence I'm using DMA in order to offload CPU...*" -- In order to "*use DMA*", you need a DMA controller (aka DMAC), which has to be programmed (with source, destination, count) for each DMA transfer. – sawdust Jun 30 '22 at 21:21
-
Thanks for pointing out my mistake, *Interrupt mode IO operation* is correctly. My main confusion comes from similarity between the functions defined in these libraries, therefore, I will try to summarize. According to manual, when *HAL_DMA_Start_IT()* (`from _hal_dma.h`) is done, **XferCpltCallback()** function will be called (part of the *__DMA_HandleTypeDef* structure), and *HAL_UART_Tx(RX)HalfCpltCallback* **will or will not be** called depending of is it USART1 global interrupt enabled or disabled. – Nemanja Jul 01 '22 at 11:44
-
On the other hand, after *HAL_UART_Transmit_DMA()* is done, function *HAL_UART_TxCpltCallback()* is called also depending of is it USART1 global interrupt enabled or disabled ( I am using STM32CubeMX, and USART1 interrupt can be enabled under *NVIC Settings* tab). – Nemanja Jul 01 '22 at 11:48