Sync SPI data

What is the best solution to sync transmitted SPI data from one device to another?

The receiving device must be able the check if the data is in sync. The receiving device could get out of sync with the transmitting device.

Should I use some kind of preamble bits in the data stream?

Reply to
Bill
Loading thread data ...

The _simplest_ solution is to pulse _SS at the end of each byte (or packet). The receiving end should be implemented to reset its rx state machine when _SS goes high.

If you don't implement the _SS line, and you are using a hardware SPI peripheral, it can be tricky; if you need to sync in to an arbitrary bitstream you'll have to implement shifting in your software since the SPI peripheral won't necessarily be lined up with the byte boundaries of the bitstream. This is made vastly more complex if you have a multimaster system. _SS is the best way to go IMHO - once the line goes high, EVERYONE on the bus knows that it's time to reset.

Reply to
larwe

Larwe's solution is quite pratical but say you don't want to do that because of some undefined reasons then adding some kind of sync data with in the data stream might work;-) For example, adding checksum of every 5 bytes in the data stream. But ofcourse it will cost you over head but an easy software solution for hardware SPIs.

ali

Reply to
Ali

IMO, consider the device as arbitrary (byte-)length of shift registers. With the CS signal common to all latch inputs, the content ist latched into the internals.

Rene

--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com
& commercial newsgroups - http://www.talkto.net
Reply to
Rene Tschaggelar

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.