> Danger, Will Robinson. PIR1 is in bank 0, you're in bank 1. I see Bob has already pointed out some bank switching problems. I deal with this issue by never "manually" messing with the RP0 and RP1 bits in status. Check out the DBANKIF and related macros in STD.INS.ASPIC at http://www.embedinc.com/pic. However, the biggest problem I see with your code is lack of comments. When you ask 2000 people to look at your code, you owe it to them (if not to yourself) to at least explain what you thought you were doing. Often you will find your own problem after being forced to explain your logic to someone else. Here's how I would write the snippet. Warning, totally untested code: ; ; Set all the EEPROM locations from 0 to 7F to the value FF. ; ; This code assumes interrupts are disabled. ; dbankif eedata movlw h'FF' ;set the data value to write to all locations movwf eedata dbankif eeadr clrf eeadr ;init next EEPROM address to write to dbankif eecon1 bsf eecon1, wren ;enable writing to the EEPROM nextadr unbank ;back each new byte to write to the EEPROM dbankif pir1 bcf pir1, eeif ;reset flag to EEPROM write not completed yet dbankif eecon2 movlw h'55' ;do the special sequence to allow EEPROM write movwf eecon2 movlw h'AA' movwf eecon2 dbankif eecon1 bsf eecon1, wr ;start the write dbankif pir1 wait_write ;back here until the EEPROM write completes clrwdt ;tell the watchdog we are still alive btfss pir1, eeif ;the write has completed ? goto wait_write ;no, go back and check again dbankif eeadr movf eeadr, w ;get the current EEPROM address xorwf h'7F' ;compare to the last address skip_nz ;not just wrote to the last address ? goto done_write ;yes, all done incf eeadr ;advance to the next address goto nextadr ;back to write to this new address done_write unbank ;all done clearing EEPROM ******************************************************************** Olin Lathrop, embedded systems consultant in Littleton Massachusetts (978) 742-9014, olin@embedinc.com, http://www.embedinc.com -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics