Writing to the flash memory of PIC18f87J90

Thread Starter

RG23

Joined Dec 6, 2010
304
I want to write the contents of count304 to memory location 4104 of pic18f87J90

I implemented the following code but did not work

movlw 0x00
movwf TBLPTRU
movlw 0x41
movwf TBLPTRH
movlw 0x04
movwf TBLPTRL
movf count304,0
movwf TABLAT
TBLWT*+
bsf EECON1, WPROG
bsf EECON1, WREN ;enable write
MOVLW 0x55 ;WRITE
MOVWF EECON2
MOVLW 0xAA ;WRITE
MOVWF EECON2
BSF EECON1,WR ;set WR bit to begin write
BTFSC EECON1,WR ;WAIT FOR
goto $-1 ;WRITE TO FINISH
bcf EECON1, WPROG
BCF EECON1, WREN ;DISABLE WRITES

If anyone has an idea please let me know

Thanks
 
Last edited:

joeyd999

Joined Jun 6, 2011
4,410
You're sequence looks correct...though I am not sure if a two-byte write works with only one byte written. The datasheet is not clear on this. Try TBLWT two consecutive values prior to committing to flash.
 
Top