1. We will be in Read Only mode (no new threads, replies, registration) starting at 9:00 EDT for a number of hours as we migrate the forums to upgraded software.

Writing to the flash memory of PIC18f87J90

Discussion in 'Embedded Systems and Microcontrollers' started by RG23, Oct 26, 2011.

  1. RG23

    Thread Starter Active Member

    Dec 6, 2010
    304
    2
    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: Oct 26, 2011
  2. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    4,230
    6,391
    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.
     
Loading...