SPI bit length

Frequent questions asked online, offline, in forums are answered here
Post Reply
TimPedersen
Posts: 1
Joined: Mon Apr 17, 2017 2:38 pm

SPI bit length

Post by TimPedersen »

Hi

I want to read date of the Hedghog using SPI and a MyRio from National Instruments. But i can't figure out what the frame length should be. I have tried 7,8 and 16 bits but nothing seems to work.
Also i would like to know if the clock phase should be Leading or Trailing edge?
If the clock polaritu shold be high or low?

Im using a a frequency of 500 kHz

smoker77
Posts: 327
Joined: Sat Feb 06, 2016 4:03 pm

Re: SPI bit length

Post by smoker77 »

Hello,

Format of frames transmitted through SPI is same as for frames transmitted through UART, and their description is in the protocol:
http://www.marvelmind.com/downloads/mar ... _12_10.pdf
As you can see, number of payload data bytes in frame is transmitted in 4-th byte of the frame. So after you receive 4-th byte, you can know the size of frame.

SPI mode 0 is used in this interface, as described in protocol by higher link.
It means CPOL=0, CPHA= 0, see the pictures here:
https://en.wikipedia.org/wiki/Serial_Pe ... erface_Bus

Post Reply