I'm trying to figure out SPI operation in the Microchip C Compiler. As I understand it, writing outgoing data to SSPBUF causes that data to be loaded into SSPSR, which then shifts it out. As data is being shifted out, input data is being shifted in to SSPSR. On completion of the shift in and out, the received data in SSPSR is put in SSPBUF so it can be read. So far so good. Looking at the C compiler library documentation on the SPI library, it LOOKS like BOTH WriteSPI and ReadSPI initiate an SPI bus cycle. It seems to me that only WriteSPI should do that. ReadSPI would then pick up the data received during the previous write. How does this actually work? Actually, I could imagine a function called SPIrw that would have a prototype of unsigned char SPIrw (unsigned char DataToSend) You'd pass it the data to send and it would return the received data. But, that doesn't seem to be how it works. So, how DOES it work? Thanks! Harold FCC Rules Online at http://hallikainen.com/FccRules Lighting control for theatre and television at http://www.dovesystems.com ________________________________________________________________ GET INTERNET ACCESS FROM JUNO! Juno offers FREE or PREMIUM Internet access for less! Join Juno today! For your FREE software, visit: http://dl.www.juno.com/get/web/. -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads