I just finished getting this going for a project. You do need to set the TRIS registers. Note the data output of the master goes to the data input of the slave and vice versa, and the chip enable of the slave needs to be addressed as well. Finally you write to the SSPBUF, give it enough time for the clocking to have taken place, then read the reply from the SSPBUF. Don't forget to clear flags and interupts before moving on. My biggest pain was getting the clock edges, idles, and data positions right. After a few hours of cut and try frustration, I sat down with the timing diagrams in the datasheets and then it worked first try. When all else fails... RTFM, LOL.




Bookmarks