Thursday, 6 February 2014

Flash memory: Does the entire page need to be erased before writing just a few bytes?


An easy question, I hope! I'm not finding any definitive answers...


I'm writing drivers for a SST25VF064C flash memory chip. It communicates via SPI.


Like all flash memory (that I know of), it needs to be erased (all bits = 1) before it can be written (bits = 0). For this chip, the smallest area that can be erased is 4kB.



Its memory is divided into 256-byte pages. With one instruction, I can write anywhere from one byte to 256 bytes into a specified page. I don't have to start on a page boundary: the first location to be programmed can be anywhere within a page.


The general rule is to make sure that the page is erased before writing into it. But, can I write into a previously-written page, if I avoid the already-written areas? For example, say that I store data into bytes 0-127. Can I later write another 128 bytes into the same page, if I start at byte 128?



Answer



Yes, after any erase, you can use any number of separate operations to write data (changing bits from 1 to 0) before the next erase operation.


You can even rewrite a previously-written location, as long as you are only clearing more bits. This can be handy for maintaining things like allocation bitmaps.


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...