Hi Folks! I am working with the pic 16f877 and I want to request some of you a code source example to be able to use the protocol I2C MSSP because I have not been able to put it into operation. I thank the borrowed time ahead of time. I have made some codes but they don't work me: void WRITEEEPROM(char DATO) { PIE1.SSPIE=0; SSPCON2.SEN=1; //Send Start Bit SSPBUF=SLAVE; //Send Adrress of device SSPBUF=MSW; //Send Word High for 24LC65 SSPBUF=LSW; //Send Word Low for 24LC65 SSPBUF=DATO; //Send Data to position SSPCON2.PEN=1; //Send Stop Bit } char READEEPROM(char MSW,char LSW) { char DATAI; PIE1.SSPIE=0; SSPCON2.SEN=1; //Send Start Bit SSPBUF=SLAVE; //Send Adrress of device SSPBUF=MSW; SSPBUF=LSW; SSPCON2.SEN=1; //Send Start Bit SSPBUF=SLAVE | 0x01; //Output SLAVE address and read option SSPCON2.RCEN=1; //Read Data of I2C port DATAI=SSPBUF; //put data in DATAI // SSPCON2.ACKEN=1; //only if is sequencial transfer //should put SSPCON2 .ACKDT before // if(SSPCON2.ACKSTAT==1) ERROR(3); //Not ACK SSPCON2.PEN=1; //Send Stop Bit return DATAI; } void IICInit(void) { ERROR1=0; //Clear error register STATUS.RP0=1; //Select page 1 // SSPCON.SSPEN=1; //Enable I2C port SSPCON=0x3E; //I2C 7 bit slave mode with mast er PORTC=0; //Set SDA, SCL low when not is tri-state //mode enabled PIE1.SSPIE=0; //desenable the interrup tion to SSP SSPADD=0xA2; //Adrress of PIC in the protocol PORTC.3=1; //Set SCL high PORTC.4=1; //Set SDA high PIR1.SSPIF=0; //Clear SSP interrupt fl ag INTCON=0xC0; //Enable interrupts SSPCON2.ACKDT=0; //It allows to place rec ognition bit STATUS.RP0=0; //Select page 0 } /******************************************************************************* ********************************************************** /******************************************************************************* ********************************************************** Ahora si en cristiano.... Hola Amigos! Yo estoy trabajando con el pic 16f877 y quiero solicitar a alguno de ustedes un csdigo fuente ejemplo para poder utilizar el protocolo I2C MSSP porque no he podido ponerlo en funcionamiento. yo he hecho algunos codigos pero no me funcionan: void WRITEEEPROM(char DATO) { PIE1.SSPIE=0; SSPCON2.SEN=1; //Manda bit de arranque SSPBUF=SLAVE; //Transfiere direccion del dispositivo esclavo SSPBUF=MSW; //Mandar palabra de direccionami ento para la memoria SSPBUF=LSW; SSPBUF=DATO; //Transfiere el dato a la Memori a SSPCON2.PEN=1; //Manda bit de parada } char READEEPROM(char MSW,char LSW) { char DATAI; PIE1.SSPIE=0; SSPCON2.SEN=1; //Manda bit de arranque SSPBUF=SLAVE; //Transfiere direccion del dispositivo esclavo SSPBUF=MSW; SSPBUF=LSW; SSPCON2.SEN=1; //Manda bit de arranque SSPBUF=SLAVE | 0x01; //Output SLAVE address SSPCON2.RCEN=1; //Lee dato del puerto I2C DATAI=SSPBUF; //coloca dato en DATAI // SSPCON2.ACKEN=1; //En caso de que fuera mas de un dato siempre //debe haber una seqal de recono cimiento del //maestro...Pero debe colocarse el SSPCON2.ACKDT // if(SSPCON2.ACKSTAT==1) ERROR(3); //No recibio reconocimiento SSPCON2.PEN=1; //Manda bit de parada return DATAI; } void IICInit(void) { ERROR1=0; //Clear error register STATUS.RP0=1; //Select page 1 // SSPCON.SSPEN=1; //Habilita el puerto I2C SSPCON=0x3E; //I2C 7 bit slave mode w ith master PORTC=0; //Set SDA, SCL low when not is tri-state //mode enabled PIE1.SSPIE=0; //Desactiva la interrupc ion del SSP SSPADD=0xA2; //Direccion del PIC en e l protocolo. PORTC.3=1; //Set SCL high PORTC.4=1; //Set SDA high PIR1.SSPIF=0; //Clear SSP interrupt fl ag INTCON=0xC0; //Enable interrupts SSPCON2.ACKDT=0; //Permite colocar bit de reconocimiento STATUS.RP0=0; //Select page 0 } Agradezco de antemano el tiempo prestado. Edinsson Ariza. __________________________________________________ Do You Yahoo!? Bid and sell for free at http://auctions.yahoo.com