Page 1 of 1

DMA vs NO-DMA for SPI Communication

Posted: Tue Feb 26, 2019 3:57 am
by e2738729
Hi everyone,

I read the IDF documentation on SPI Master and I was confused about the use of DMA.

Under Speed and timing consideration, both Non-DMA Interrupt and Polling are faster than DMA driven Interrupt and Polling. So what is really the purpose of DMA in this context? Doesn't DMA free the CPU to handle other tasks?

"When the DMA is enabled, it needs about 2us per transaction to setup the linked list. When the master is transferring, it automatically read data from the linked list. If the DMA is not enabled, CPU has to write/read each byte to/from the FIFO by itself. Usually this is faster than 2us, but the transaction length is limited to 64 bytes for both write and read."

If my data transfer is less than 64 bytes, then DMA is actually worse than no-DMA, am I correct?


Thanks.

Re: DMA vs NO-DMA for SPI Communication

Posted: Tue Feb 26, 2019 7:04 am
by ESP_Sprite
The issue is that it takes longer to set up a transfer with DMA than one without. DMA, however, allows you to do transfers >64 bytes without CPU interference, so if you can do large transfers, DMA is better.

Re: DMA vs NO-DMA for SPI Communication

Posted: Wed Feb 27, 2019 3:23 am
by e2738729
Thank you for your reply. In my case, since I have to mux through each channel of the ADC using SPI commands, and each time I only collect 4 bytes (24 bits to be exact) and the sampling rate is 500Hz, I guess DMA will not be useful for me.

Re: DMA vs NO-DMA for SPI Communication

Posted: Wed Feb 27, 2019 3:54 am
by ESP_Sprite
I would agree on that.