Hi,
I initially used the the SSPSTAT.0 bit for both sending and receiving but eventually got into trouble. Darrel then made me aware in this thread of that the purpose of SSPSTAT.0 flag really is when the PIC is operating in slave mode and data is shifted into to PIC by an external clock source, ie when something else is providing the SPI clock. (Thanks Darrel!)
When the PIC is acting as the master, as is the case in all your examples, it works fine with the interrupt flag. For shifting in a byte you simply write a "dummy" value to SPPBUF, the module will then shift that dummy byte out with 8 clockpulses and then you'll have your input byte in SSPBUF.
IF you're going to use the SSPSTAT.0 bit I suspect you want to poll it before reading SSPBUF to see if there's a byte available to be read. The way you have in your latest post you grab whatever is in SSPBUF and then sit there waiting for another byte before continuing. Is that the intentended operation?
/Henrik.
Bookmarks