The 819 erases Flash in blocks of 32 WORDS.
Those blocks are restricted to physical boundaries, not just 32 words from where you said to erase.
With $04F0, the beginning of the block it will erase is at $04E0.
Make the lowest 5-bits 0 to find the beginning.
Then when writing, you have to write in blocks of 4 WORDS. These blocks also have physical boundaries.
After erasing from $4E0, the first write block is from $4E0 to $4E3.
Anything written to those locations will be transferred to flash memory only AFTER the 4th location is written too.
But your FOR loop is only writing every other word, so it would write to the 1st and 3rd locations, and the data will never be transferred to Flash.
Plus the loop should only go to 31 instead of 63. You're writing WORD's not BYTE's.
Bookmarks