Has anyone implemented serial EEPROM reading and or writing with High Tech's PIC C compiler? I'm using a PICDEM-2 with a PIC16C74. I have attempted to write some code using the included i2c subroutines with no luck. If anyone has done this, could you please post the way to do it? Here is what I have so far: When this code runs, I get both errors and the code erroneously reports -1 as the value of all 128 EEPROM locations. Thanks! Jeff Fisher jfisher@mail.accesscomm.net /******************************** * INCLUDES ********************************/ #include #include "delay.h" #include #include "i2c.h" void Initialize(void); void startUP(void); void dumpEEPROM(void); void Initialize(void) { INTCON = 0x00; // disable all interrupts ADCON1 = 0x02; // set all porta inputs to analog all porte pins in digital mode TRISA = 0xFF; // all analog pins on porta are not assigned TRISB = 0xE0; // B5, B6, B7 are button inputs, rest are outputs TRISC = 0x80; // C7, which is serial RX is the only input on portc TRISD = 0x00; // portd is all outputs TRISE = 0x00; // porte is all outputs TXSTA = 0x26; // turn on USART RCSTA = 0x90; // turn on USART SPBRG = 25; // 9600 baud } void putch(char c) { TXREG = c; while (1) { // wait here until done if ( TXSTA & 0x02 ) break; } } void startUP(void) { } void main (void) { Initialize(); startUP(); dumpEEPROM(); while (1) { } } void dumpEEPROM(void) { unsigned char counter = 0; unsigned char error; int temp; SSPCON = 0x3B; // setup master i2c mode via software SSPADD = 80; // configure clock i2c_Restart(); error = i2c_Open(0xA0, I2C_READ); if ( error == 1 ) printf("i2c_Open ERROR #1"); error = i2c_ReadFrom(0xA0); if ( error == 1 ) printf("i2c_ReadFrom ERROR #2"); printf("EEPROM Dump:\n"); putch(0x0D); while (counter != 128) { temp = i2c_GetByte(I2C_MORE); // get byte from EEPROM printf("%d : ",counter); // output address printf("%d\n",temp); putch(0x0D); // output data and CR/LF counter++; } }