I'm trying to write and read bytes from a 24LC02 with the MSSP module (16F877 built-in) but I believe I'm making some mistakes in my code. The pic is running at 4MHz (xtal mode). I'm using hitech c compiler. First: What's the correct value I have to load in SSPADD for 400kHz? And for 100kHz? (I prefer400KHz, if possible at this clock frequency...) Second: The pull-up resistor for SDA and SCL are currently 2k2. Is it ok for 400KHz? Third: The 16F877 datasheet (p. 61 to 104) and the "THE I2C-BUS AND HOW TO USE IT" from Philips explains I2C operation in a shrink fashion. Probably they omitted some things that I can't discover. Fourth: The E2PROM must be external (can't use internal). For a while, I don't wish interrupts occurring for I2C operation (GIE = 0 when the executing code reach a I2C write or read routine). Actually My program has to do a simple task: The USART receive bytes as 9600bps and, between one byte and another, the MSSP record the received byte in sequential positions in the 24LC02. The bytes I send are manually inserted in the USART by a simple Qbasic routine running in my computer, so, there's enough time for write to the I2C memo before receive the next USART byte. After 8 chars (1page), the pic stop accept bytes form the USART and start to show the bytes recorded (in the 24LC02) at PORTA. (It's true PORTA is 6-bit wide, but its first four bytes are enough to show decimal number in a CD4511 (BCD -> 7 segments decoder IC). Resuming: I type something (decimal numbers) in my keyboard and the pic has the responsibility to record these bytes at 24LC02 and after 8 bytes, it has to stop receiving USART data and begin to read the 24LC02 and show its contents in a 7 segments display (there are delay routines in order to allow 7-segments visualization). The entire code works fine, expect for the write and read routine I wrote for control the MSSP module. The code parts that aren't working as I want are shown below. Also, What values SSPSTAT,SSPCON, SSPCON2 and SSPADD should be for 400KHz operation? Is there something missing? Does I have to put acknowledge or it's automatic after SSPBUF write? Flag bits must be manually set? Another ways or entire routines for MSSP read write control (I2C mode) are welcome. (I did read the philips docs about I2C, Mchip 24LC02 and 16F877 datasheet.) See you, Roberto. _____________ Sub-routine for WRITE bytes in 24LC02: SEN = 1; //create a START condition SSPBUF = 0b10100000+0;//This is the "name" for 24LC02 plus the R/W bit in WRITE position SSPBUF = memo_address; // The memory position I wish to write SSPBUF = RCREG; //Records the USART buffer byte inside 24LC02 PEN = 1; //create a STOP condition Memo_address++; Sub-routine for READ bytes in 24LC02: GIE = 0; for (memo_address = 0;memo_address<=8;i=i+1) { SEN = 1; SSPBUF = 0b10100000+0; SSPBUF = memo_address; SEN = 1; SSPBUF = 0b10100000+1; PORTA = SSPBUF; //show recorded bytes in a 7segment PEN = 1; }; ____________________________________________________________________ Get your own FREE, personal Netscape WebMail account today at http://webmail.netscape.com.