EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Flash-cells can be used as downcounters - ?

Started by karthikbg November 11, 2006
Hi,

I came across something as below while i was looking for downcounters.
And this is really interesting !!

" Downwriting is possible in Flash Memory .
Flash-Cells are proberly usable as downcounters.
Start with bytewise "FF" and ure able to reprogram this flash-cell with
every value
that means not to bring a flash-data-BIT from "0" to "1". "

How is it possible to make the Flash memory to act like downcounters ?

I am using S29GL512N MirrorBit=E2=84=A2 Flash. (Spansion Flash).

Share your views/ideas .

Thx in advans,
Karthik Balaguru

karthikbg wrote:

> " Downwriting is possible in Flash Memory . > Flash-Cells are proberly usable as downcounters. > Start with bytewise "FF" and ure able to reprogram this flash-cell with > every value > that means not to bring a flash-data-BIT from "0" to "1". " > > How is it possible to make the Flash memory to act like downcounters ?
Not sure if it's what you mean, but after you erase a sector it is filled with an all-ones pattern. You can then program (clear) each bit one by one, and implement a simple counter. So, you'd start with writing binary 11111110, then overwrite the same byte with 11111100, 11111000, ... 10000000, 00000000. After that, you move on to the next byte. This can be a useful technique if you absolutely must commit every event to flash.
Arlet wrote:
> karthikbg wrote: > > > " Downwriting is possible in Flash Memory . > > Flash-Cells are proberly usable as downcounters. > > Start with bytewise "FF" and ure able to reprogram this flash-cell with > > every value > > that means not to bring a flash-data-BIT from "0" to "1". " > > > > How is it possible to make the Flash memory to act like downcounters ? > > Not sure if it's what you mean, but after you erase a sector it is > filled with an all-ones pattern. You can then program (clear) each bit > one by one, and implement a simple counter. So, you'd start with > writing binary 11111110, then overwrite the same byte with 11111100, > 11111000, ... 10000000, 00000000. After that, you move on to the next > byte. > > This can be a useful technique if you absolutely must commit every > event to flash.
Thx for your reply. That is a pretty good idea. But, I believe that there are many issues in using this method. In the case of reprogramming, EEPROM is reprogrammable bytewise . But, FLASH is not bytewise programmable(usually). The only way to change one byte in a block of Flash is To : 1) Copy the entire block to RAM (or other media) 2) Change the byte in the copy created in RAM. 3) Erase the Flash block and reprogram it with the entire image. It looks a bit big way ( The efficiency interms of speed will decrease & Footprint memory will increase a bit) !! For using this option, we can use the in-built hardware counters / our own software counters . what do you think ? Or Is there any other way of doing the Flash Memory to act as downcounters ? Thx in advans, Karthik Balaguru
karthikbg wrote:

> > Not sure if it's what you mean, but after you erase a sector it is > > filled with an all-ones pattern. You can then program (clear) each bit > > one by one, and implement a simple counter. So, you'd start with > > writing binary 11111110, then overwrite the same byte with 11111100, > > 11111000, ... 10000000, 00000000. After that, you move on to the next > > byte. > > > > This can be a useful technique if you absolutely must commit every > > event to flash. > > Thx for your reply. > That is a pretty good idea. But, I believe that there are many issues > in using this method. > > In the case of reprogramming, > EEPROM is reprogrammable bytewise . But, FLASH is not bytewise > programmable(usually). > > The only way to change one byte in a block of Flash is To : > 1) Copy the entire block to RAM (or other media) > 2) Change the byte in the copy created in RAM. > 3) Erase the Flash block and reprogram it with the entire image.
Not true. Flash can be bytewise programmed, as long as you're only *clearing* bits. In order to *set* bits, you'll need to perform an erase cycle, and this erase the entire sector. In fact, in your step 3 where you 'reprogram it with the entire image', you are writing one byte at a time.
In comp.arch.embedded,
karthikbg <karthik.balaguru@lntinfotech.com> wrote:
> > In the case of reprogramming, > EEPROM is reprogrammable bytewise . But, FLASH is not bytewise > programmable(usually). > > The only way to change one byte in a block of Flash is To : > 1) Copy the entire block to RAM (or other media) > 2) Change the byte in the copy created in RAM. > 3) Erase the Flash block and reprogram it with the entire image. >
What kind of flash are you referring to? Your steps seems valid for some kind of flash memory card. On a flash device like the AM29LV080 you can program a single byte just fine, erasing is done per sector. -- Stef (remove caps, dashes and .invalid from e-mail address to reply by mail)
karthikbg wrote:
> The only way to change one byte in a block of Flash is To : > 1) Copy the entire block to RAM (or other media) > 2) Change the byte in the copy created in RAM. > 3) Erase the Flash block and reprogram it with the entire image.
This is untrue. Erasing a block turns all of its bits to ones. You can then change any of the ones to zeros without erasing again. Only when you need to turn a zero into a one do you need to erase a block (or move to a different block). The Flash that I've seen allow modifying a single byte at a time. -- Darin Johnson
Arlet wrote:
> karthikbg wrote: > > > > Not sure if it's what you mean, but after you erase a sector it is > > > filled with an all-ones pattern. You can then program (clear) each bit > > > one by one, and implement a simple counter. So, you'd start with > > > writing binary 11111110, then overwrite the same byte with 11111100, > > > 11111000, ... 10000000, 00000000. After that, you move on to the next > > > byte. > > > > > > This can be a useful technique if you absolutely must commit every > > > event to flash. > > > > Thx for your reply. > > That is a pretty good idea. But, I believe that there are many issues > > in using this method. > > > > In the case of reprogramming, > > EEPROM is reprogrammable bytewise . But, FLASH is not bytewise > > programmable(usually). > > > > The only way to change one byte in a block of Flash is To : > > 1) Copy the entire block to RAM (or other media) > > 2) Change the byte in the copy created in RAM. > > 3) Erase the Flash block and reprogram it with the entire image. > > Not true. Flash can be bytewise programmed, as long as you're only > *clearing* bits.
Be careful of absolutes, someone will come along with an exception :) In this case I know of an exception, the Philips/NXP LPC2000 series use ECC on their internal flash. The effect of which is to make it not possible to write any 16 byte block a second time w/o erasing the sector it's in. If you clear a bit that was previously set the ECC will kick in and 'correct' the value, and since you will be unknowingly update the ECC code at the same time the corrected value isn't easily predictable. Robert
On 2006-11-13, karthikbg <karthik.balaguru@lntinfotech.com> wrote:

>> Not sure if it's what you mean, but after you erase a sector it is >> filled with an all-ones pattern. You can then program (clear) each bit >> one by one, and implement a simple counter. So, you'd start with >> writing binary 11111110, then overwrite the same byte with 11111100, >> 11111000, ... 10000000, 00000000. After that, you move on to the next >> byte. >> >> This can be a useful technique if you absolutely must commit every >> event to flash. > > I believe that there are many issues in using this method. > > In the case of reprogramming, EEPROM is reprogrammable > bytewise.
Yes.
> But, FLASH is not bytewise programmable(usually).
Yes, it is. It's just not bytewise erasable.
> The only way to change one byte in a block of Flash is To : > 1) Copy the entire block to RAM (or other media) > 2) Change the byte in the copy created in RAM. > 3) Erase the Flash block and reprogram it with the entire image.
Wrong. You can program a single byte in all of the flash devices I've used. You just can't erase a single byte.
> what do you think?
It works exactly the way it was described to you. I've done it.
> Or Is there any other way of doing the Flash Memory to act as > downcounters?
-- Grant Edwards grante Yow! I have seen these at EGG EXTENDERS in my visi.com Supermarket... I have read theINSTRUCTIONS...
Robert Adsett wrote:

> > Not true. Flash can be bytewise programmed, as long as you're only > > *clearing* bits. > > Be careful of absolutes, someone will come along with an exception :)
The good part about using absolutes is that people will be eager to correct you if you're wrong, which provides an opportunity to learn something new :)
> In this case I know of an exception, the Philips/NXP LPC2000 series use > ECC on their internal flash. The effect of which is to make it not > possible to write any 16 byte block a second time w/o erasing the > sector it's in. If you clear a bit that was previously set the ECC > will kick in and 'correct' the value, and since you will be unknowingly > update the ECC code at the same time the corrected value isn't easily > predictable.
Interesting. I've worked with the LPC2xxx processors, but had not tried accessing the flash from the application yet.
Arlet wrote:
> Robert Adsett wrote: > > > > Not true. Flash can be bytewise programmed, as long as you're only > > > *clearing* bits. > > > > Be careful of absolutes, someone will come along with an exception :) > > The good part about using absolutes is that people will be eager to > correct you if you're wrong, which provides an opportunity to learn > something new :)
Touche :) Robert

Memfault Beyond the Launch