Hi piclisters. I am doing an application using PICC V8.01 PL3 with 2 PIC17C756A, one is my I2C master and the other is the slave. The master one is already communicating with an E2PROM, so this part is OK. The master is also already sending commands to the slave, and this is OK. Now I need a reply from the slave, one or three bytes long. Could anyone check this "macro" (function calling) sequence and find what's wrong? Master side: Start_I2C(); Write_I2C(DeviceAddress); Write_I2C(ComandSetReply); RestartI2C(); WaitIdleI2C(); Write_I2C(DeviceAddress | 0x01); ReadI2C(); WaitIdleI2C(); AckI2C(); Buffer[0] = SSPBUFF; if ( !(SSPBUF & 0x04) ) // condition if reply is 1 or 3 bytes { RestartI2C(); WaitIdleI2C(); Write_I2C(DeviceAddress | 0x01); ReadI2C(); WaitIdleI2C(); AckI2C(); Buffer[1] = SSPBUF; RestartI2C(); WaitIdleI2C(); Write_I2C(DeviceAddress | 0x01); ReadI2C(); AckI2C(); Bufer[2] = SSPBUF; } Stop_I2C(); Slave side (real C): void interrupt perif_int(void) @ 0x0020 { PEIF = 0; if (SSPIF) { SSPIF = 0; if ( !STAT_RW ) { Command = SSPBUF; } else { if (!STAT_BF) { switch (ReadPhase) { case 0: SSPBUF = Status; CKP = 1; if (!(Status & 0x04) // condition if reply is 1 or 3 bytes ReadPhase++; else ReadPhase = 0; break; case 1: SSPBUF = pos_pulsos.bytes[0]; CKP = 1; ReadPhase++; break; case 2: SSPBUF = pos_pulsos.bytes[1]; CKP = 1; ReadPhase=0; break; } } } } } Any help would be highly appreciated Thank you all Francisco > > -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu