Hello everyone. I have a project where 4 slaves (pic16F876) and 1 master (pic16F877) will be using i2c to communicate. I'm pretty new to pics but can do PicBasic easily enough. But the PicBasic i2c stuff doesn't work for my project (why not?) and I need to use assembler to read and write between the 16F877 and 16F876's. I've spent a few days on this already without success and I'm getting confused about when to send Acks, Nacks, Stops, etc. If some kind person could list the sequence of events for an i2c read and an i2c write (on the master side - I believe the slave code is fine) and what needs to be done in software and when it needs to be done. I will be eternally grateful. Although I need to do the read/write's in assembler I'll be doing the rest of the code in PicBasic (for speed: the code needs to be ready for shipping at the end of this month). The most urgent difficulty is getting the read to work. Here's where I'm at - at the moment (it doesn't work properly). Thank you very much for reading this and helping out. loop: Pause 1000 currentAddress = 17 call SetStart call i2cSendAddress call i2cReadByte inData[0] = SSPBUF call i2cAck call i2cReadByte call i2cNack call i2cStop goto loop ' Do it forever end asm _SetStart banksel PIR1 bcf PIR1, SSPIF banksel SSPCON2 bsf SSPCON2, SEN btfsc SSPCON2, SEN goto $-1 bcf STATUS, RP0 return endasm asm _i2cSendAddress bcf STATUS, C movf _currentAddress, w banksel SSPBUF movwf SSPBUF banksel SSPSTAT btfsc SSPSTAT, R_W goto $-1 bcf STATUS, RP0 return endasm asm _i2cReadByte banksel SSPCON2 bsf SSPCON2, RCEN ;generate read condition btfsc SSPCON2, RCEN goto $-1 bcf STATUS, RP0 return endasm asm _i2cStop banksel PIR1 bcf PIR1, SSPIF banksel SSPCON2 bsf SSPCON2, PEN banksel PIR1 btfss PIR1, SSPIF goto $-1 endasm asm _i2cAck banksel SSPCON2 bcf SSPCON2, ACKDT bsf SSPCON2, ACKEN bcf STATUS, RP0 return endasm Cheers, Peter P Duthie, software engineer, CDLtd -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu