SPI with DMA on XMEGA

Droopy
Benutzer
Avatar
Gender:
Age: 58
Posts: 24
Registered: 01 / 2016
Subject:

SPI with DMA on XMEGA

 · 
Posted: 24.08.2016 - 17:08  ·  #1
I have the XMEGA256A3U and sending out 1024 bytes over a SPI bus. Before sending and after the send command I switch an output port. The difference between port high and low is the time it takes to send out those bytes.
The time it takes (depending of cource on the frequency) is about 400µsec when I just send it out with "MSPIout_D1(@Buf,Sizeof(Buf));
Now I added the "MSPIDMA_OUT_D1 = DMAch0;" to the defines to send it out with DMA support. The time it takes now is about 1000µsec.

I know what DMA is and how it works with a PC system, but my question is, if I understand it right for the XMEGA and AVRCO:
- I can imagine that sending out with DMA takes longer because of handling issues and because it has to wait for free slots to access the ram. But at the other side it does occupy the CPU much less because it is done while the CPU is performing other tasks: so spending less cpu runtime.
- When programming the send command with DMA, the code behind the command is only executed after the finishing of data sending with DMA. So it doesn't help you because it doesn't execute other code at the moment, or does it automatic do a 'shedule' to other processes at the mean time?

Thanks for some more information.
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: SPI with DMA on XMEGA

 · 
Posted: 24.08.2016 - 17:26  ·  #2
Hello Droopy,

the function MSPIDMA_OUT_xx waits until the DMA signals a transfer ready.
So you don't gain any CPU time here. The only benefits with DMA is reduced
code size and Interrupts and Multiprocessing Task changes don't disturb the
transfer.

rolf
Droopy
Benutzer
Avatar
Gender:
Age: 58
Posts: 24
Registered: 01 / 2016
Subject:

Re: SPI with DMA on XMEGA

 · 
Posted: 24.08.2016 - 17:50  ·  #3
Thanks Rolf.
Cause the posibility of interruption is not an issue for me, I better don't use DMA: it's faster ;)
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: SPI with DMA on XMEGA

 · 
Posted: 24.08.2016 - 21:34  ·  #4
Hello Droopy,

yes, the XMega DMA uses cycle stealing which doesn't burden the CPU
very much, but is slower than standard SPI driving.

rolf
Droopy
Benutzer
Avatar
Gender:
Age: 58
Posts: 24
Registered: 01 / 2016
Subject:

Re: SPI with DMA on XMEGA

 · 
Posted: 24.08.2016 - 23:43  ·  #5
So the DMA controller is now configurated to transfer for instance 1000 bytes automatic without interference of the CPU. If the CPU would not wait for completion and directly go further, we would gain cpu run time, but at a slower transfer rate...
Especially for controlling a display, it would be great. Video ram, defined in AVR ram, can be transferred to the display without losing much cpu run time. Only an interrupt is needed to flag completion and set back the display chip select. The rate of transfer is not that important, except for the tearing effect when using moving pictures ;)
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 14 · Cache Hits: 14   96   110 · Page-Gen-Time: 0.042801s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI