# SPI speed for High speed data acquisition

Discussion in 'The Projects Forum' started by zhangz64, Aug 17, 2013.

1. ### zhangz64 Thread Starter New Member

May 1, 2013
7
0
Hi
guys,

Our team is using the SPI interface on the raspberry pi to communicate with the GP22 chip(Time to digital converter)
The GP22chip is used to measure the time difference between 2 stop signals.
For the best performance ,Our project requires a measurement rate of 500Khz which is the maximum measurement rate the chip can offer
In order to reach that, We contacted the supplier and they give us a timing model which we need to follow closely in order to reach that rate.(Attachment below)

We are able to configure the chip to follow the Timing between the Fake_Start and the interrupt, However , we failed to get the SPI to work as fast as they have required.(Transfer 3 bytes with in 1.2uS == 20Mhz SPI clock speed!) We only got 5 Mhz SPI clock speed.(We set to 15.6 Mhz)

My question is that Did the SPI on raspberry pi reached its speed limit or i simply measured the SPI speed wrong?
Based on the information i found here , the max speed he got is 32Mhz

The way i measure the spi speed is to use this while loop below to iterate 100000 times then use this time function to get the running time .

Code ( (Unknown Language)):
1.
2. clock_t begin=clock();
3. while(t--)
4.      {
5.           char buf11 [] = { 0xB0, 0xff, 0xff, };    //read result
6.           bcm2835_spi_transfern(buf11, 5);
7.      }
8. clock_t end=clock();
9.
Then i calculate spi speed using. SPI_Speed= 100000/*Time_Diff *3*8 (3 means 3 bytes, 8 for 8 bits for each byte)
We are using the bcm2835 library with a divider of 16(15.6 Mhz)

The result we got is the rate of sending 3 bytes is 200 Khz which equals to 5Mhz SPI speed (200k*3*8).
Did i measure it wrong?
Also, when i try to use a divider of 8(32Mhz) The spi on raspberry PI is not working properly.(I shorted MOSI adn MISO to test the SPI, the transmitted is not the same as received )

We used the modified version of spidev_test.c before but the ioctl is too slow for our project, so we switched to BCM2835 library.
and followed it closely to remove all the 10 uS delays in the source code. But still the SPI speed is not even close to what we wanted

Also, if there is any PI user, It would be great if you can share your experience of increasing SPI speed.

First of all, please excuse me if my question is seemly easy or my bad English. I am a first year undergraduate ECE student doing summer research . There is a lot of stuff i have to learn. I tried to research this topic on the internet and could not find a affirmative answer for my case. I found my self stucked near end of the project and hope i can get some help here.

Best Regards,

Zhen

File size:
15 KB
Views:
36
2. ### simo_x Member

Dec 23, 2010
200
6
Regarding SPI clock speed, you should check the datasheet of the IC device mounted on the board.