Search code examples
cflashmicrocontrollereeprom

how to erase single page of m25p40 flash without erasing other pages?


I am using m25p40 flash memory with jn5148 MCU.In datasheet of this flash , it is written that:

Erase capability:

  • Sector erase: 512Kb in 0.6 s (TYP)
  • Bulk erase: 4Mb in 4.5 s (TYP)

I am facing problem in overwriting data stored in one page of sector. So , how can I erase one page, and write new data in that page? Is there any solution to erase one page of sector, without erasing other pages of same sector?


Solution

  • Here is a sector erase procedure quoted from the documentation on m24p40

    The SECTOR ERASE command sets to 1 (FFh) all bits inside the chosen sector. Before the SECTOR ERASE command can be accepted, a WRITE ENABLE command must have been executed previously. After the WRITE ENABLE command has been decoded, the device sets the write enable latch (WEL) bit. The SECTOR ERASE command is entered by driving chip select (S#) LOW, followed by the command code, and three address bytes on serial data input (DQ0). Any address in- side the sector is a valid address for the SECTOR ERASE command. S# must be driven LOW for the entire duration of the sequence. S# must be driven HIGH after the eighth bit of the last address byte has been latched in. Otherwise the SECTOR ERASE command is not executed. As soon as S# is driven HIGH, the self-timed SECTOR ERASE cycle is initiated; the cycle's duration is t SE . While the SECTOR ERASE cycle is in progress, the status register may be read to check the value of the write in progress (WIP) bit. The WIP bit is 1 during the self-timed SECTOR ERASE cycle, and is 0 when the cycle is completed. At some unspecified time before the cycle is completed, the WEL bit is reset. A SECTOR ERASE command is not executed if it applies to a sector that is hardware or software protected.

    enter image description here