jackzhang273
Posts: 5
Joined: Wed Aug 27, 2014 6:24 pm

SPI DMA

Wed Aug 27, 2014 10:56 pm

Hi,

Can some one give some example as how to set up SPI with DMA?

I have the SPI set up to a FPGA where the FPGA is sending in data and the data needs through the SPI into the memory via DMA.

I searched online and found bcm2835 library, but I couldn't find example as to how to set up SPI with DMA.

Thanks,

Jack

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: SPI DMA

Thu Aug 28, 2014 12:52 am

There was some discussion here about SPI and DMA... don't remember all the details though, but maybe something in there will help?

User avatar
joan
Posts: 14887
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: SPI DMA

Thu Aug 28, 2014 7:19 am

It would help if you could indicate the performance you require.

Are you planning to use the Linux spidev driver? That seems to be currently limited to the region of 20 thousand SPI calls per second (so 20ksps from an ADC). I'm not sure if it uses DMA or not (user msperl should know, he is developing a DMA patch for spidev). http://www.raspberrypi.org/forums/viewt ... lit=msperl

I've used DMA to bit bang SPI at 500kbps, which allowed me to read 25ksps. An advantage of bit banging is you can parallel up reads of identical chips so can get 25ksps per chip (this assumes the message fits within 20 bits). http://www.raspberrypi.org/forums/viewt ... 41#p514141

You can go faster if you bypass the spidev drivers and use the hardware directly. Circa 100,000 sps. http://www.raspberrypi.org/forums/viewt ... 44&t=84159

The overall caveat is you may end up using 100% CPU to capture your samples and have no time left to process them.

Return to “Beginners”