Write_EEPROM_Addr_w ;load w with address, load EEWriteData with data, then call here
TryDisableInts
bcf INTCON,GIE ;disable ints
btfsc INTCON,GIE
goto TryDisableInts
bsf STATUS,5 ;bank 1 (all EEPROM regs are in bank 1)
movwf EEADR ;set addr
clrf EEADRH ;set high addr to 0 (16F688)
movf EEWriteData,w ;get data (shared memory)
movwf EEDATA ;place data
bcf EECON1,EEPGD ;enable EEPROM writes
bsf EECON1,WREN ;enable eeprom writes (rem for testing and unrem when ready)
movlw 0x55 ;start of required sequence
movwf EECON2
movlw 0xAA
movwf EECON2
bsf EECON1,WR ;start of write, end of sequence
WaitForEEPROMWriteComplete
btfsc EECON1,WR
goto WaitForEEPROMWriteComplete
bcf EECON1,WREN ;disable any more EEPROM writes
bcf STATUS,5 ;back to bank 0 before return
;bsf INTCON,GIE ;enable ints
return