I have already read several forsums regarding this subject but I still cannot get my code to work. I followed the steps outline in the PIC16f877 data sheet but still cannot write to EEPROM.
Here is my code:
Since this is a macro, I call it in the following way:
And in the beginning of my program I do this to reserve space for ADDr and VALUE:
Does anyone see anything wrong with any of this? Any help is appreciated.
Here is my code:
EEPROM_Write macro ADDR, VALUE;
bcf STATUS, RP0
bsf STATUS, RP1
movf ADDR, W
movwf EEADR
movf VALUE, W
movwf EEDATA
bsf STATUS, RP0
bcf EECON1, EEPGD
bsf EECON1, WREN
bcf STATUS, RP1
bcf INTCON, GIE
bsf STATUS, RP1
movlw 0x55
movwf EECON2
movlw 0xAA
movwf EECON2
bsf EECON1, WR
bsf INTCON, GIE
bcf EECON1, WREN
bcf STATUS, RP1
bcf STATUS, RP0
endm
Since this is a macro, I call it in the following way:
movlw 0x00
movwf ADDR
movlw 0x00
movwf VALUE
EEPROM_Write ADDR, VALUE
And in the beginning of my program I do this to reserve space for ADDr and VALUE:
udata
Table_Counter res 1
Delay1 res 1
Delay2 res 1
Delay3 res 1
ADDR res 1
VALUE res 1
Does anyone see anything wrong with any of this? Any help is appreciated.