Searching \ for '[PIC]: PIC18F flash write (from MASTERs 2003 730-B' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/memory.htm?key=flash
Search entire site for: 'PIC18F flash write (from MASTERs 2003 730-B'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: PIC18F flash write (from MASTERs 2003 730-B'
2004\07\04@064314 by Philip Pemberton

face picon face
Hi,
 Does anyone happen to know what's wrong with the code on slide 24 of the
"PIC18F Bootloader" (730 BOT) presentation from Microchip's MASTERS 2003
conference?
 Near as I can tell (by comparing the code to other 18F loader code), it's
overrunning the buffer on the last loop. Aside from that, I can't see
anything obviously wrong with it. The code in question is:

;GIVEN:
;  FSR0   -> points to first of 8 bytes of a buffer
;            that will be written
;  TBLPTR -> points to first byte of 8 byte block in
;            internal user memory
;  COUNTER = 8
;  WRITEIT = Correct programming macro

WRITE_TO_HREGS
      movff POSTINC0,TABLAT     ; looad Holding Regs
      TBLWT*+                   ;
      decfsz COUNTER            ;
      bra WRITE_TO_HREGS        ;
      WRITEIT                   ; Write Holding Regs
                                ;  to user memory

Ordinarily I wouldn't ask. but the fact that I've gone over this code at
least a dozen times and still haven't found the problem is driving me mad!

Later.
--
Phil.                              | Acorn Risc PC600 Mk3, SA202, 64MB, 6GB,
spam_OUTphilpemTakeThisOuTspamdsl.pipex.com              | ViewFinder, 10BaseT Ethernet, 2-slice,
http://www.philpem.dsl.pipex.com/  | 48xCD, ARCINv6c IDE, SCSI
... FLATTERY: telling a person exactly what he thinks of himself.

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu

2004\07\04@081341 by Jason Harper

picon face
Phil wrote:
> WRITE_TO_HREGS
>        movff POSTINC0,TABLAT     ; looad Holding Regs
>        TBLWT*+                   ;
>        decfsz COUNTER            ;
>        bra WRITE_TO_HREGS        ;
>        WRITEIT                   ; Write Holding Regs
>                                  ;  to user memory

I've never done anything with table writes myself, but I'm pretty sure that
you have to leave TBLPTR pointing within the 8-byte block when you actually
do the write.  This means that the final byte can't use TBLWT*+, as this
leaves TBLPTR just beyond the block.
       Jason Harper

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamKILLspammitvma.mit.edu

2004\07\04@092813 by Philip Pemberton

face picon face
In message <.....200407040813_MC3-1-85DD-ACBEKILLspamspam.....compuserve.com>>          Jason Harper <EraseMEJasonRandHarperspam_OUTspamTakeThisOuTCOMPUSERVE.COM> wrote:

> I've never done anything with table writes myself, but I'm pretty sure that
> you have to leave TBLPTR pointing within the 8-byte block when you actually
> do the write.  This means that the final byte can't use TBLWT*+, as this
> leaves TBLPTR just beyond the block.
Isn't it strange how the simple stuff always evades detection? :)
I've just checked the data sheet and you're right - the PIC uses all but the
least significant three bits for the write block address, then the eight
bytes that are going to be programmed are loaded from the PIC's internal
8-byte buffer. That would mean that if you loaded 8 bytes, the post-increment
would increment the buffer, writing the data 8 bytes higher than it was
supposed to be written.
Easy when you know how, or so the saying goes.
Now I just need to work out how to erase the config memory before updating it
(if such a thing is possible or, in fact, required).

Thanks,
--
Phil.                              | Acorn Risc PC600 Mk3, SA202, 64MB, 6GB,
philpemspamspam_OUTdsl.pipex.com              | ViewFinder, 10BaseT Ethernet, 2-slice,
http://www.philpem.dsl.pipex.com/  | 48xCD, ARCINv6c IDE, SCSI
... Anything worth doing is worth overdoing.

--
http://www.piclist.com hint: To leave the PICList
@spam@piclist-unsubscribe-requestKILLspamspammitvma.mit.edu

More... (looser matching)
- Last day of these posts
- In 2004 , 2005 only
- Today
- New search...