Shawn, Looks OK to me. You do need a common ground on the Pics. You also need 2 pullup resistors on the data and clock lines. I would say about 10k up to +5v would do you here. Brian. -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Shawn Van Every Sent: 08 November 2003 17:30 To: PICLIST@MITVMA.MIT.EDU Subject: [PIC] I2C Troubles Hey All, I have been trying to implement a basic I2C demonstration between 2 PIC 16F877s using CCS PIC C. One PIC is the master and the other the slave. Unfortunately I am a bit unclear about the wiring and the code. So, if anyone out there has the inclination, I have a couple of questions: First, do I need to have a common ground between the PICs? I have tried the following master and slave code with several different wiring configurations but none seems to work, any ideas? MASTER: #include <16F877.h> #fuses XT,NOWDT,NOPROTECT,NOLVP,PUT /* Delay for 4 mhz crystal */ #use delay (clock=4000000) /* Setup RS232 */ #use rs232(baud=9600, xmit=PIN_D4,rcv=PIN_D5, INVERT) /* Setup I2C */ #use I2C(MASTER, sda=PIN_C4, scl=PIN_C3, SLOW) main() { char send_char = 65; int8 i2c_command = 66; while (true) { delay_ms(100); putc(send_char); delay_ms(100); putc(send_char+1); delay_ms(100); /* Master */ i2c_start(); // Start condition i2c_write(0xa0); // Device address i2c_write(i2c_command); // Write Command i2c_stop(); // Stop condition } } SLAVE: #include <16F877.h> #fuses XT,NOWDT,NOPROTECT,NOLVP,PUT /* Delay for 4 mhz crystal */ #use delay (clock=4000000) /* Setup RS232 */ #use rs232(baud=9600, xmit=PIN_D4,rcv=PIN_D5, INVERT) /* Setup I2C */ #use i2c(SLAVE, SDA=PIN_C4, SCL=PIN_C3, address=0xa0, SLOW, FORCE_HW) #INT_SSP void ssp_interupt () { byte incoming; incoming = i2c_read(); putc(incoming); } main() { char send_char = 65; int received_char = 0; int i2c_received; while (true) { delay_ms(100); putc(send_char); enable_interrupts(GLOBAL); enable_interrupts(INT_SSP); /* Slave */ ////i2c_start(); ////i2c_write(0xa1); //i2c_received = i2c_read(1); ////i2c_stop(); //putc(i2c_received); } } -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.