rom1nux
rom1nux

Reputation: 110

dsPic33 page erase size

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 :

B/ I do an empirical test to verify and i found 0x600 address per page, this mean 1024 instructions is :

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 ?

Upvotes: 0

Views: 1191

Answers (1)

rom1nux
rom1nux

Reputation: 110

I confirm now 1024 instructions erase page is :

  • 4096 bytes (phantom byte included) [1024 instructions x 4 bytes]
  • 3072 utile bytes. [4096 bytes x 0.75]
  • We need 2048 (0x800) address unit [4096 / 2] to address a page

Be careful to do you test erase-page aligned because if you erase a page at an address in the page, the whole page is erased, this is why my empirical conclusion was bad.

Page 0 : 0x000000 to 0x0007FE
Page 1 : 0x000800 to 0x000FFE
Page 2 : 0x001000 to 0x0017FE
Page 3 : 0x001800 to 0x001FFE
Page 4 : 0x002000 to 0x0027FE
...
Page 84 : 0x02A000 to 0x02A7FE
Page 85 : 0x02A800 to 0x02AFFE (Last page contain flash config bytes)
Page 86 : 0x02B000 (Inexistent page)

Upvotes: 1

Related Questions