OK, after those results, I'm compelled to go out on a limb.
That limb is to say that...- PBP is wrong, by declaring BLOCK_SIZE as 64 bytes. But I can't blame them, because....
- 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>
Bookmarks