2022-02-03 01:13 AM
If I want to do some communication using SPI or UART, there are options like DMA or Interrupt, both of which give me callback. That means after MCU issues or start Tx/Rx function, it is free to do something else while waiting for the Tx/Rx complete callback.
Can anyone enlighten me what are the pros and cons of using DMA or interrupt? Is DMA always preferred?
Solved! Go to Solution.
2022-02-03 01:49 AM
Hello @HDaji.1 ,
What you need to know about Interrupt and DMA is the CPU usage. DMA works independently of CPU, in this way some tasks can be executed when receiving data from SPI/UART. DMA will load/store data in memory that you have allocated for. Interrupt needs some clock cycles to enter into the subroutine, then execute it and exit the ISR. During this time, all tasks are stopped.
The choice between interrupt and DMA depends of your application, but generally DMA is preferred and especially when memory for computing or communication IPs are used in continuous.
Even if DMA doesn't need interrupt to work, it's possible to configure some if you need (for example trigger IRQ after each DMA transfer or DMA error occurs).
I hope it will help.
Best regards,
Gwénolé
2022-02-03 01:49 AM
Hello @HDaji.1 ,
What you need to know about Interrupt and DMA is the CPU usage. DMA works independently of CPU, in this way some tasks can be executed when receiving data from SPI/UART. DMA will load/store data in memory that you have allocated for. Interrupt needs some clock cycles to enter into the subroutine, then execute it and exit the ISR. During this time, all tasks are stopped.
The choice between interrupt and DMA depends of your application, but generally DMA is preferred and especially when memory for computing or communication IPs are used in continuous.
Even if DMA doesn't need interrupt to work, it's possible to configure some if you need (for example trigger IRQ after each DMA transfer or DMA error occurs).
I hope it will help.
Best regards,
Gwénolé
2022-02-03 02:01 AM
Thx. I got the idea.