I am attempting to test the table read/write of the PIC18f2431. I understand that tables are written 8 bytes at a time meaning that the TABLAT register is written to 8 times. I start by setting the table pointer as follows:
MOVLW 0x00 MOVWF TBLPTRU MOVLW 0x10 MOVWF TBLPTRH MOVLW 0x00 MOVWF TBLPTRL
This should set the pointer to address 0x1000. Next I load the TABLAT register 8 times such as:
MOVLW 0x## MOVWF TABLAT TBLWT*+
* * *I then set the EECON1 and EECON2 registers as follows:
BCF EECON1,CFGS BSF EECON1,EEPGD BSF EECON1,WREN BCF INTCON,GIEL BCF INTCON,GIEH MOVLW 0x55 MOVWF EECON2 MOVLW 0xAA MOVWF EECON2 BSF EECON1,WR NOP BCF EECON1,WREN
At this point the 8 bytes that I transfered to the TABLAT should be written to program memory at 0x1000 right? When I attempt to read back the data, I set the table pointer to 0x1000 just like I did before the write sequence. I use the TBLRD*+ and then read the contents of the TABLAT register. I get
0xFF. When I download the program memory from the PIC into MPLAB, I can see that the data was written starting at 0x1008. What's strange is that the last byte I loaded into TABLAT before the write appears at 0x1008. The byte at 0x1009 contains the first byte that I wrote to TABLAT and then the sequences continues as expected. Is this correct? I would have expected the first byte that I transferred to TABLAT would appear at 0x1000, the second at 0x1001 and so on.