Scott wrote: > In Master mode, the BF and R_W bits go high on a write to SSPBUF. BF > goes low after the 8th bit is written. After the 9th (/ACK) bit is > clocked in, R_W goes low and SSPIF is set. Seems to me that either one > of these bits can be polled to determine when SSPBUF can be written to > again. Isn't BF the buffer full bit? If so, isn't that the obvious bit to use to determine whether the buffer is full or not? RW may have some different logic. If they give you a bit specifically to tell you whether the write buffer is full, using anything else is just asking for trouble. > I also wrote an interrupt-based I2C routine that acts on the SSPIF > flag, and this works just fine. Wow, who'd have thought that if you use the bits according to their purpose the code works correctly!? > I'm still curious to know why polling > R_W once doesn't work, but polling it twice does work... Because it's meant for something else and doesn't work the way you think, obviously. This should be no surprise given they gave you a separate bit just for what you are trying to do. ******************************************************************** Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products (978) 742-9014. Gold level PIC consultants since 2000. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist