Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to measure the SPI speed properly?

Status
Not open for further replies.

zhangz64

Junior Member level 3
Joined
May 1, 2013
Messages
25
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,632
Hi
guys,

Our team is using the SPI interface on the raspberry pi to communicate with the GP22 chip(Time to digital converter)
Data sheet of GP22 **broken link removed**
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.
image008.png

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:
clock_t begin=clock();
while(t--)
     {
          char buf11 [] = { 0xB0, 0xff, 0xff, };    //read result 
          bcm2835_spi_transfern(buf11, 5);
     }
clock_t end=clock();

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.
We found this thread
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.

Please advise, Thanks ahead

Best Regards,

Zhen
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top