Hi Stew
I have code that stores a set of about 20 values in dataEEPROM. It is ages since I looked at this but below is an edited version of my write and read subroutines. I read and write the data from/to a series of registers so I have simply indicated a silly name for single registers in this example. The process is tricky because you have to go through a sequence of events and then wait for the write process to complete. First thing is to tell the device which EEPROM location you want to write to / read from. In my case this is the value stored in 'byte_count'.
This is on a PIC16F8127. I looked very quickly and the control registers for dataEEPROM in your PIC seem the same.
Maybe best to have a look at this stuff and come back with further questions.
Good luck.
Mike
write_byte
BANKSEL byte_count
movf byte_count, W BANKSEL EEADRL
movwf EEADRL ; place current value of byte_count into EE address reg.
movf value_to_be_stored, W
BANKSEL EEDATL
movwf EEDATL ; copy data at current register to EEDATL
bcf EECON1, CFGS ; select programme & data space
bcf EECON1, EEPGD ; select data
bsf EECON1, WREN ; enable writes
bcf INTCON, GIE ; disable interrupts
movlw 55h
movwf EECON2
movlw 0AAh
movwf EECON2
bsf EECON1, WR ; start write operation
bsf INTCON, GIE ; enable interrupts
bcf EECON1, WREN ; disable writes
BTFSC EECON1, WR ; wait for any current write operation to complete.
goto $-2
return
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
read_byte
BANKSEL byte_count
movf byte_count, W
BANKSEL EEADRL
movwf EEADRL ; place current value of byte_count into EE address reg.
bcf EECON1, CFGS ; select programme & data space
bcf EECON1, EEPGD ; select data
bsf EECON1, RD ; start EEread
movf EEDATL, W
BANKSEL register_to_be_written
movwf register_to_be_written ; move latest data byte into relevant register.
return