Paul Duffy wrote: > void write(char data, char address) //writes 8 bit data to address in eeprom > { > eedata = data; > eeadr = address; > eecon1 = 0b00000100; > eecon2 = 0x55; > eecon2 = 0xAA; > eecon1 = 0b00000110; > while(test_bit(eecon1,1)); //wait for write to complete > eecon1 = 0; > pir1 =0; //clear interrupt flages - PIR1<7> > } Try writing the write() routine in assembler, or at least the write sequence (55,AA,WR). Note that the datasheet specifies that the exact sequence shown must be used, and you don't know how the C compiler might do it. Here's the EEPROM write protocol, in assembler: BSF EECON1,WREN ;Enable writes BCF INTCON,GIE ;Disable INTs. ; BEGIN REQUIRED EXACT SEQUENCE MOVLW 55h ; MOVWF EECON2 ;Write 55h MOVLW AAh ; MOVWF EECON2 ;Write AAh BSF EECON1,WR ;Set WR bit to ;begin write ; END REQUIRED EXACT SEQUENCE BSF INTCON,GIE ;Enable INTs. BCF EECON1,WREN ;Disable writes -- Hector Martin (hector@marcansoft.com) Public Key: http://www.marcansoft.com/marcan.asc -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist