DMA vs NO-DMA for SPI Communication

e2738729
Posts: 35
Joined: Mon Nov 05, 2018 6:22 pm

DMA vs NO-DMA for SPI Communication

Postby e2738729 » Tue Feb 26, 2019 3:57 am

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.

ESP_Sprite
Posts: 9766
Joined: Thu Nov 26, 2015 4:08 am

Re: DMA vs NO-DMA for SPI Communication

Postby ESP_Sprite » Tue Feb 26, 2019 7:04 am

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.

e2738729
Posts: 35
Joined: Mon Nov 05, 2018 6:22 pm

Re: DMA vs NO-DMA for SPI Communication

Postby e2738729 » Wed Feb 27, 2019 3:23 am

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.

ESP_Sprite
Posts: 9766
Joined: Thu Nov 26, 2015 4:08 am

Re: DMA vs NO-DMA for SPI Communication

Postby ESP_Sprite » Wed Feb 27, 2019 3:54 am

I would agree on that.

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 56 guests