1

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?

halfer
  • 19,824
  • 17
  • 99
  • 186
  • If you only can erase one sector, an not a single page, then you have to copy the whole sector, erase it, then write the sector back (with the modified page). If it's possible to erase a single page, then it should be in the data sheet, read it thoroughly! – Some programmer dude Jul 25 '14 at 08:55
  • But in that case unnecessary delay will be added.it will take at-least 2 sec for modifying just one page content !!! I want to use this flash for real time data storing. – Dhaval Chauhan Jul 25 '14 at 09:22

3 Answers3

1

You cannot rewrite one page. You must rewrite one sector at least. So if you want change a.k.a rewrite at least one byte in any page in choosen sector you can do following:

  1. Read ALL sector to RAM.
  2. Erase this sector.
  3. Change needed data in RAM.
  4. Write back changed data to flash's sector.

YOU MUST READ THIS ARTICLE: Five things you never knew about flash drives

Denys Yurchenko
  • 333
  • 5
  • 10
0

According to the datasheet:

The memory can be programmed 1 to 256 bytes at a time using the PAGE PROGRAM command. It is organized as 8 sectors, each containing 256 pages. Each page is 256 bytes wide.

Although I don't know if it actually works, and I cannot test it, I also found that someone already did this with an avr µC, which should give you an example function write(address, word) if you don't want to read the page program sequence (datasheet p.27) and write your own.

Emilien
  • 2,385
  • 16
  • 24
-1

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

Ruslan Gerasimov
  • 1,752
  • 1
  • 13
  • 20