Erasecode,Writecode,Readcode - again


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    OK, after those results, I'm compelled to go out on a limb.

    That limb is to say that...
    1. PBP is wrong, by declaring BLOCK_SIZE as 64 bytes. But I can't blame them, because....
    2. Microchip is wrong, since their datasheet says the Flash must be written 64 bytes at a time.

    It seems apparent that the 18F8722 only has 8 holding registers for flash writes (regardless of what the datasheet says). It does erase 64 bytes at once. But you can only write 8 bytes at a time. Coincidently, that's the same as the 18F8720, it's predecessor.

    I may be eating crow by the next post. But I'm pretty sure this will work...
    Code:
    AA VAR WORD
    BB VAR WORD
    CC VAR WORD
    DD VAR WORD
     X VAR BYTE
     
    ERASECODE $1F00
    
    TBLPTRU = 0
    TBLPTRH = $1F
    TBLPTRL = 0
    for X = 0 to 7
        gosub Write8
    next X
    
    Gosub ShowFlash
    
    stop
    ;_____________________________________________
    Write8:
        For BB = 0 to 7
            TABLAT = BB.Lowbyte
            @ tblwt*+
        NEXT BB
        TBLPTRL = TBLPTRL - 1
        EECON1 = $84
        EECON2 = $55
        EECON2 = $AA
        ASM
            bsf   EECON1, WR
            nop
            bcf   EECON1, WREN
        endasm
        TBLPTRL = TBLPTRL + 1
    return
    
    ShowFlash:
        For CC = $1F00 to $1F3F STEP 2
            READCODE CC,DD
            HSEROUT [HEX4 CC," ",HEX4 DD,13,10]
        NEXT CC
        HSEROUT [10]
    return
    Then, assuming that works. Simply changing BLOCK_SIZE EQU 64 to, BLOCK_SIZE EQU 8 in the 18F8722.INC file should fix it.

    The only thing I have here to test it on is an 18F6720, which is also Erase 64/write 8. And it works here....

    Prepare to feed me my Crow.
    <br>
    DT

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    WORKS!

    Thanks again!



    Anybody from Microchip out there listening? You owe Darrel at least a dinner!
    Charles Linquist

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Charles Linquis View Post
    WORKS!

    Thanks again!



    Anybody from Microchip out there listening? You owe Darrel at least a dinner!
    And I have to wonder how and why my PICKIT2 works with the '8722 if it's actually using the datasheet specifications.
    Apparently, Microchip is holding out on the datasheet info and/or revisions/errata again...

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Charles Linquis View Post
    WORKS!
    Oh thank God!
    It's always so hard to get the feathers out of my teeth.
    DT

  5. #5
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Thanks to a mis-labeled board (it actually had an 8720 on it, rather than an 8722), I really got things screwed up.

    And it turns out that MC's documentation is indeed correct - the 8720 has a block size of 8 bytes, while the 8722 has a block size of 64 bytes.

    Everything is working now. I *would* let Darrel feed me some of that crow, but I'm a vegetarian !
    Charles Linquist

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Omg!

    And let that be a lesson to everyone.

    Never trust your test equipment unconditionally.
    Especially when it's not electronic.

    Ok well, I suppose I'll have a few feathers for dinner, but I can see you're not going to chow down willingly, mr vegan. So just to make sure, I've put a heaping helping in your avatar.
    DT

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    And let that be a lesson to everyone.

    Never trust your test equipment unconditionally.
    Especially when it's not electronic.

    Ok well, I suppose I'll have a few feathers for dinner, but I can see you're not going to chow down willingly, mr vegan. So just to make sure, I've put a heaping helping in your avatar.
    I'll trade ya some spaghetti for some of that crow
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  8. #8
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Spaghetti sounds good.

    But some floss for the feathers would be better.
    <br>
    DT

  9. #9
    Join Date
    Apr 2010
    Location
    Walnut Creek, CA
    Posts
    17


    Did you find this post helpful? Yes | No

    Default Re: Erasecode,Writecode,Readcode - again

    Good golly, this works. I fussed around with PBP WRITECODE for way too long and gave up, modified Darrel's code slightly, and it works! Here's my code. Thanks Darrel!

    Code for PIC18F8722:

    FOR IX = 0 TO 63 ' for DEBUG
    FLASH_WRITE_BUFF[IX] = IX + 64 ' for DEBUG
    NEXT IX ' for DEBUG
    ' DEBUG WRITE FLASH PROGRAM MEM TEST
    ERASECODE FLASH_MEM_START
    FOR IX = 0 TO 63 ' load TBLAT
    TABLAT = FLASH_WRITE_BUFF[IX]
    @ tblwt*+
    NEXT IX
    TBLPTRL = FLASH_MEM_START
    EECON1 = $84
    EECON2 = $55
    EECON2 = $AA
    ASM
    BSF EECON1, WR
    NOP
    BCF EECON1, WREN
    ENDASM
    TBLPTRL = TBLPTRL + 1
    ' DONE WRITING FLASH PROGRAM MEM TEST

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts