Hi Neil, Note that I added BANKSEL directives to your code. I'll leave it up to you to see which ones could be removed because of redundancy. I may have made some boo-boos, so double-check things carefully. Like I said before, you can add code to this routine to see if interrupts were enabled or not. Then based on this boolean condition, you can conditional enable or leave interrupts disabled upon exit. You might also want to investigate the state of WRERR upon power-up. Have you checked all errata notes on the PIC16F627? Just for kicks, you also might want to check the WR bit to ensure it is getting cleared after a write completes. Also (depending upon the situation) it is good practice to point the EEPROM address register to another unused location upon exit as one of several measures to help prevent corruption of the EEPROM location you just wrote. ;----------------------------------------------------------------- ; Write data to EEPROM (location supplied in W, data in E_DATA) ;----------------------------------------------------------------- WriteEEData: BANKSEL PIR1 bcf PIR1,EEIF ; Reset write-complete flag BANKSEL EEADR movwf EEADR BANKSEL E_DATA movf E_DATA,W ; Get data to be stored BANKSEL PIR1 bcf PIR1,EEIF ; Ensure interrupt flag off while in bank 0 BANKSEL EEDATA movwf EEDATA ; Previous BANKSEL also takes care of the following registers bsf EECON1,WREN ; Enable writes bcf INTCON,GIE ; Disable interrupts movlw H'55' ; Special seq movwf EECON2 ; ... movlw H'AA' ; ... movwf EECON2 ; ... bsf EECON1,WR ; Start write operation bcf EECON1,WREN ; Disable writes bsf INTCON,GIE ; Re-enable interrupts BANKSEL PIR1 WriteEEWait: btfss PIR1,EEIF ; Check EEIF flag for write completion goto WriteEEWait WriteEEDataDone: return Hope this helps more than it hurts. :) Best regards, Ken Pergola -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body