I work on dsPic33EP256MC502 application, i need to write on flash to save configuration. All work except erasing page, i erase too much or too many.
Datasheet say page erase page size is "1024 instructions" (3072 bytes) Since instruction is 24 bits + phantom byte, instruction is 32 bits aligned We need two address unit to address an instruction
Example :
0x000000 : [Phantom] [Instruction1] [Instruction1] [Instruction1]
0x000002 : [Phantom] [Instruction2] [Instruction2] [Instruction2]
0x000004 : [Phantom] [Instruction3] [Instruction3] [Instruction3]
0x000006 : ...
A/ Naively i compute 1024 instructions page size like :
- 4096 bytes (phantom byte included) [1024 instructions x 4 bytes]
- 3072 utile bytes. [4096 bytes x 0.75]
- So we need 2048 address unit [4096 / 2] to address a pages : 0x800 address per page
B/ I do an empirical test to verify and i found 0x600 address per page, this mean 1024 instructions is :
- 0x600 is 1536 address
- 3072 bytes (phantom byte included) [1536 x 2 bytes]
- 2304 utile bytes [3072 bytes x 0.75]
- I found erase page is 768 instructions [3072 / 4]
I don't understand how the datasheet count instructions with or without the phantom byte, three or four bytes ? How many address per page is available ?
Can someone help me to understand my mistake and/or get a good point of view ?