SPI reads only around 17K samples per second

Hi everyone,

I am using Jetson TX2 to read ADC samples via SPI interfacing. I enabled SPI and tested it with the loopback test, it works fine. After being sure that SPI works correctly, I connect the MISO pin to read data from the ADC (MOSI pin is not connected as the controller does not write to the peripheral, but only reads data from it). Since I am more comfortable with Python, I use Python Spidev library to read ADC samples. Below is a part of the code I use to read data:

spi = spidev.SpiDev()
spi.mode = 0b00
spi.cshigh = False
spi.lsbfirst = False
spi.max_speed_hz = 25000000 #25M Hz is the maximum

while True:
except KeyboardInterrupt:

In function displaySignal(), I write the returned bytes to a file for further analysis of the audio signal… Since the signal itself is noisy, I need to be sampling it at a high frequency. However, for some reason, I can acquire only around 17K samples per second. The clock frequency is 25MHz and when I probe it with an oscilloscope I can see that the data to SPI MISO pin has a period of 40 nano seconds as expected. Do you know why I read data at a much lower rate than the ADC transmits?

Any help is greatly appreciated. I am really stuck and I don’t have much background on this.


Did you verify by spidev_test to narrow down it?


Hi ShaneCCC,
What do you mean by narrowing it down? I run spidev_test.c and I receive the transmitted message back. Do you mean playing with the clock frequency in spidev_test.c? Please let me know how I implement what you suggest.

You can try spidev_test -s to set the frequency if able to configure the speed.

I will do that. To clarify: so, you are suggesting that I see this problem because I use Python lib to read the samples and if I switch to C I will read samples at higher frequency? I am asking this because I have already set the spi_max_frequency to 25MHz in the above code. While I can see the clock frequency matches with the set frequency, I just read samples at a much lower rate.

Quick update: based on my understanding so far, there are at most around 20K ioctl SPI transfers per second. Increasing the clock speed does not increase the number of transfers per second. I can probably send a larger chunk of bytes at each transfer, but it is not a useful workaround for me as I need to record timestamp for each transfer of 2 bytes, separately.

My question is: does anyone achieve better than 20K ioctl transfers per second? If so, how? Please be explicit. It is hard to understand the answer when the answer is not meant to be explanatory.