> >Here is my question: How do I write the code so that > >the Slave knows which byte is the "command" byte and > >which byte is a "data" byte? I have been using SPI to send a packet from one controller to the PIC (Kronos Robotics Dios chip) using the following protocol: 254 -- Start-of-packet signal motor -- 0-6, selects motor to control speed -- 0-15, selects speed direction -- 0-2 (forward, backward, braking) 0 -- sent so that the controller can read the checksum Basically I create a small state-machine, which an integer listing what state I should be in. If I get a bad value at any time, I abort the transaction and the sender doesn't get a valid checksum, so the sender resends the entire packet. I added the checksum because otherwise is is difficult to know if the reciever has actually recieved the packet. I hope this helps. -- D. Jay Newman ! I can bring whole cities to ruin, jay@sprucegrove.com ! And still have time to get a soft-shoe in... http://enerd.ws/ ! -- from Buffy, "Once More with Feeling" -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu