Can anyone see why this data EEPROM routine doesn't work?, it's driving me mad
I'm using a 16F648a, and I've used the same routine on the 16F628 in the past.
I'm using a 16F648a, and I've used the same routine on the 16F628 in the past.
Code:
; ***********************************************************************
; EE_Write - Routine to write a byte to EEPROM
; Address in EE_Address, data in W
EE_Write
bsf STATUS, RP0 ; Bank 1
bsf EECON1, WREN ; Enable write
bcf INTCON, GIE ; Disable INTs
movwf EEDATA ; set EEPROM data
movfw EE_Address
movwf EEADR ; set EEPROM address
movlw 0x55
movwf EECON2 ; Write 55h
movlw 0xAA
movwf EECON2 ; Write AAh
bsf EECON1, WR ; Set WR bit
bsf INTCON, GIE ; Enable INTs
; begin write
bcf STATUS, RP0 ; Bank 0
btfss PIR1, EEIF ; wait for write to complete.
goto $-1
bcf PIR1, EEIF ; and clear the 'write complete' flag
bsf STATUS, RP0 ; Bank 1
bcf EECON1, WREN ; Disable write
bcf STATUS, RP0 ; Bank 0
return