Saving data in flash

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Saving data in flash

Jump to solution
1,652 Views
juliancox
Contributor V

I need to save one byte of data in flash and recover it when my S08-based unit is next switched on. The data will need to be saved many times over a relatively short period of time (say once per minute) as its value is changed by the user. What is the easiest way to do this (pity it doesn't have any EEPROM on board).#

0 Kudos
1 Solution
1,061 Views
vicentegomez
NXP TechSupport
NXP TechSupport
0 Kudos
4 Replies
1,061 Views
juliancox
Contributor V

I have been looking at the Codewarrior Flash component IFsh1. As I only need to save (and read) one byte where the new value will overwrite the old value, Is there any reason why I should nor use this component with the "write method" set to "Destructive write (with erase"? It seems such a simple solution that there must be a catch.

0 Kudos
1,061 Views
mfugere
Contributor III

Depends on what you expect the total number of write/erase cycles may be for a typical life of the product.   The manufacturers usually guarantee a certain number of write/erase cycles for flash cells, and the chips will frequently exceed that limit, but by how much - who knows?   For many microcontrollers, this number is around 100,000 cycles.  I would say that if you think that you're going to write a value more than ~100,000 times over the expected life of the product, that you will use a whole buffer area like I described so you avoid wearing out that one cell/byte - and then no longer are able to store updated values in it.   What wears the flash out is the erase cycle (turning back into 1s) all the "0" bits that end up getting programmed when you write new value.   You can only change a "1" bit  to a "0" bit with a write, you must erase the sector of flash to turn the "0" bits back int "1"s.

0 Kudos
1,061 Views
mfugere
Contributor III

You probably already know this, but one can wear out the flash in CPU if one writes/erases the very same location many many times.   What I do when I need to store small amounts of data into system flash is to reserve a block or page, or some reasonable size sector of flash that is significantly alrger in size than my data record I must store, and treat it as a  queue for storing the data - always just read to the first erased byte and back up 1 to get the latest data.  When one hits the end of the reserved area and doesn't encounter erased flash -> indicates it is time to erase the whole block and start over at the beginning.   This is a very  simplistic "wear leveling" and have products that are in the field for years without problems.  Depending on your needs, this may work perfectly fine for your application.

0 Kudos
1,062 Views
vicentegomez
NXP TechSupport
NXP TechSupport

Please check the following threads

Unable to write S08 flash in run mode 

Emulated EEPROM on S08 devices. 

https://community.nxp.com/message/829692 

I hope this will help you.

Regards

Vicente Gomez

0 Kudos