I tried searching here and other places. What is the best way to access the SPI and get the fastest speed out of it. My project involves interfacing the Pi with an ADC that is rated for 5Msps (http://www.linear.com/product/LTC2315-12). I searched online to see how I would get started, and stumbled upon a how-to (http://hertaville.com/2013/07/24/interfacing-an-spi-adc-mcp3008-chip-to-the-raspberry-pi-using-c/). The article dealt with a 10-bit 200Ksps ADC. The author also mentioned that due to constraints, it would be difficult to achieve anything above 100Ksps. But supposedly, the SPI on the Pi is rated for upwards of 32Msps (according to the elinux page for the Pi SPI).

So is it possible for me to get the Pi SPI running at 5Msps. If so, how would I go about starting? Would I use the shell, a C program, Python program, etc.? Are there "lower-level" methods to get at the hardware. If anyone is wondering, I plan on converting the data into sound and storing it in a WAV file.

Any information is welcome.


You have misread the eLinux site. SPI on the Pi can manage a transmission bit rate of 32 Mbps, i.e. bits per second not samples per second.

The "official" SPI driver tops out at about 20ktps (twenty thousand transactions per second).

If you talk directly to the SPI hardware you can manage perhaps 100ksps for 12 bit samples. E.g. http://lb.raspberrypi.org/forums/viewtopic.php?p=595597#p595597

I'd expect 100k transactions per second is pretty much a limit. If you can squeeze more than one sample into a transaction you might get higher sample rates. The chips I've used only provide a sample per transaction.

  • What's the difference between samples-per-second and bits-per-second? Is a sample a full byte of data? – Max Jacob Mar 16 '15 at 0:25
  • The bits per second is the underlying medium transmission rate. For some ADCs many bits are needed to get each sample. For instance the MCP2302 require 24 bits to be transferred for each 12 bit sample, so the sample rate is at most 1/24th of the bit rate. In practice it will be slower because of other overheads. The underlying Linux system call is a SPI transfer (send/receive a number of bytes). You can only call SPI transfer of the order of 20k times per second on the Pi before the CPU is saturated... – joan Mar 16 '15 at 8:52
  • ... You can do better by talking to the hardware directly. Chips like yours seem to stream readings. They are an unknown quantity as far as I am concerned. – joan Mar 16 '15 at 8:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.