I am writing to flash memory of LPC2136. Do I need to erase the segment before writing Because i wrote garbage when i write to Flash after doing segment preparation only. every thing fine If i do in following way 1.)prepare the segments 2.)erase the segments 3.)prepare the segments 4.)write to segments Is there any thing wrong or this the only method to write to flash. my worries is whether each time do i need to erase 32kb segment to write. so i need a copy of this 32kb in the ram. Regards murale
Can i write 1 or 0 as the same way with out considering the previous state(1 or 0) of the flash? No, not unless this is a really unusual flash technology. "Erasing" a flash device means setting all the bits to 1. "Programming" a flash means setting some bits to 0. "Programming" cannot set a bit to 1, and "erasing" cannot set a bit to 0. Physically, a bit of flash memory is like a little electron corral, surrounded by a "fence" of impassable potential. Pack a bunch of electrons into the corral, and the bit represents a 1. Open a hole in the fence, and connect the corral to ground, and all the electrons run out. Then the corral has a value of 0. "Erasing" a flash means pumping up the internal voltage to the point where you can force electrons into the corral despite the fence around it. Older flash parts used to have an extra high voltage Vcc input used just for this operation. Flash has a limited lifetime in terms of erase cycles because this is a fairly brute-force sort of operation, and eventually it wears down the potential barriers around the flash cells to the point where they no longer reliably pen up electrons. Once electrons can wander in and out of the corrals at their own whim, the device is no longer a reliable storage medium. For chip layout, density, and cost-per-bit reasons, the circuitry to do the programming isn't done on a per-bit basis. Making each bit independently eraseable would cost too much. Instead, large numbers of bits are grouped together into "pages" or "sectors". All the bits in a sector must be erased at the same time. "Programming" the flash means selectively opening up some of those cells and letting the electrons leak out. Whereever there is a 0 in the word to be programmed, the flash device drains electrons from the corresponding cell. Programming does nothing to the cells where there is a 1 in the data to be programmed. Those cells will keep their previous value. You can program a flash multiple times without erasing it, but all you can do each time is change 1s to 0s. You can never changes 0s to 1s without using the "erase" operation.
Thank you very much for the detail discription Drew Davis best Regards murale