Search code examples
dmastm32cubemx

How to setup NVIC for DMA in STM32CubeMX?


I am trying to connect STM32G070 microcontroller with Quectel BC660K-GL via UART in DMA mode. I am using STM32CubeMX for programming. I understand basic principles how DMA works, therefore settings inside the DMA Settings tag are quite clear to me, but I don't understand the NVIC Settings tag, namely, should I check or uncheck USART1 global interrupt / USART1 wake-up interrupt through EXTI line 25 (shown in figure 1): Fig.1: NVIC Settings There is a bunch of tutorials online but I can't find more information about this topic.


Solution

  • If you use DMA for UART communication, then it is DMA and UART, who talk to each other and decide when to load/store next byte of data. USART interrupts are needed if you want to have an interrupt handler for UART for when some USART event occurs, such as byte received or frame error or transmission complete or other. But if you want DMA to handle the communication, USART and DMA can do it between themselves without your intervention. Interrupts are, in fact, not required at all for DMA to function. It will know when to load/store new piece of data without any interrupts. Therefore, USART interrupts would be unnecessary.

    Normally, it is only DMA interrupts you would be interested in. Since DMA took over control over sending/receiving data, it is DMA flags that will require your attention - transfer complete or transfer error, for example. Unless you have some specific reason to react to some USART event, you don't need USART interrupts, and neither does DMA.