Is there a trade-off for memory to memory DMA transfer when the data size is small?

前端 未结 3 507
小鲜肉
小鲜肉 2021-01-24 11:41

I am learning about the STM32 F4 microcontroller. I\'m trying to find out about limitations for using DMA.

Per my understanding and research, I know that if the data si

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-24 12:20

    As @Vinci and @P__J__ already pointed out,

    1. A DMA controller works autonomously and doesn't create overhead on the CPU it supplements (at least not by itself). But:

    2. The CPU/software must perform some instructions to configure the DMA and to trigger it or have it triggered by some peripheral. For this, it needs CPU time and program memory space (usually ROM). Besides, it usually needs some additional RAM in variables to manage the software around the DMA.

      Hence, you are right, using a DMA comes with some kinds of overhead.

    And furthermore,

    1. The DMA transfers make use of the memory bus(es) that connect the involved memories/registers/peripherals to the DMA controller. That is, while the DMA controller does its own work, it may cause the CPU which it tries to offload to stall in the meantime, at least for short moments when the data words are transferred (which in turn sum up for longer transfers...).

    On the other hand, a DMA doesn't only help you to reduce the CPU load (regarding total CPU time to implement some feature). If used "in a smart way", it helps you to reduce software latencies to implement different functions because one part of the implementation can be "hidden" behind the DMA-driven data transfer of another part (unless, both rely on the same bus resources - see above...).

提交回复
热议问题