This is a BAD example because we Erase the first block and can never enter the loader again after RESETTING the PIC.
But atleast this code writes what it should.
for i=0 to 4 'erase first 5 blocks
Flash = n*64
ERASECODE Flash
next i
for n=0 to 255
FLASH=n
WRITECODE FLASH, n
next n
I didn't really look into why, but your software does not write correctly. As I have said a million times:
DO NOT USE FORMULAS INTO READCODE AND WRITECODE
It just doesn't seem to work (no arrays, no cute stuff, nothing except as below!)
use ONLY a WORD variable for the address and a BYTE or WORD variable for DATA
/me
Bookmarks