> I am using SPI protocol to exchange data between two PICs. The master > will send the "location" byte first (to tell the slave where the data > should be written to) and the actual data byte. How should I write the > code so that the slave knows which byte is As long as you always send exactly two bytes and both parts are reset at the same time, they should stay in sync. SPI is usually done with a separate chip enable line from the master to each slave. The slave resets its protocol state when first enabled. If this is the only slave on the bus, it could assume it stays in sync as above, but also reset protocol whenever a sufficiently long time between bytes has been detected. Of course this only works if the slave sends both bytes within a guaranteed maximum time. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads