Dear friends, I'm trying to communicate to a device that uses a strange variant of SPI. I'm looking for short and easy to understand code/ideas, not necessarily super-optimized code. This should be easy. It's sending out clock pulses and data bits, and the SPI port on my 16F87x is recieving them just fine. But that device sends out a random (often not a multiple of 8) number of clock pulses between "packets", and it expects me to sync up to the fixed header bytes of each packet. I have some code that watches for the header byte and calculates N (in the range 0..7), which tells me exactly how many clock pulses off the SPI reciever is (ugly, but works for now). I keep thinking I can (a) somehow nudge the SPI reciever (how?), get it to sync up so I can read "real" bytes directly at interrupt time and store them in my buffer. (Don't other people have this same problem if the PIC wakes up right in the middle of a SPI transmission ?) But if I can't do that, I suppose I could do it brute force: (b) buffer up an entire (unaligned) packet, and the whole thing N bits to the right. (c) For each byte, copy it and the previously recieved byte to a 16 bit register, shift N bits to get the "real" byte, and store that away in my buffer. (d) other ? -- David Cary -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu