MK22FX512AVLL12 counter implementation

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

MK22FX512AVLL12 counter implementation

861 Views
dusek_martin
Contributor IV

Hi,

I have some spare flash in MK22FX512AVLL12 and I would like to use it for non-volatile monotonous counter implementation. The counter counts some events. When event occurs, it increments by one. The counter implementation should be aware of flash wear, the max. number of events to occur during device lifetime is 5 milions. The implementation fo the counter should use min. amount of flash memory.

Single programming command of MK22FX512AVLL12 can program 4 bytes data at 8 bytes memory boundary.

Thanks for any advise.

0 Kudos
4 Replies

848 Views
mjbcswitzerland
Specialist V

Hi

With 4k sector size and 8 byte phrase programming a sector can be written to 512 times (in different phrases) before it needs to be erased. That means that a 4k sector can be used to count from 0 to 511 per erase cycle.
2 sectors increases the count to 262'144 before the second sector gets full and needs to be erased (whereby the second sector counts the number of times the first has been erased - each time by writing in the next available phrase).
3 sectors can count to 134 million before the third sector gets full.
Typically 100'000 erase cycles are quoted, which means that the first sector could be used to count from 0 to 51 million before it would typically fail.

Since, in this case, it is the first sector that is being subjected to wear and the others less - by moving this counter around across a number of physical sectors would spread its wear and ensure a higher life time (or swapping the sectors definition to move the faster counter to the slow counter one after a certain number of overall counts).
However, taking 10'000 erase cycles as safe limit still allows 5 million event counts without needing to resort to wear leveling methods in 3 x 4k sectors.

3 sectors will be required for simplest implementation although 2 could be used with a more complicated system where the counting information saved included more details so that it can always recover (with worst case a single lost event count) when a power cycle/reset takes place during a counting operation.

Regards

Mark

 

0 Kudos

853 Views
dusek_martin
Contributor IV

Thanks for the point about write endurance. Now the question is how write endurance is counted by MK22FX512AVLL12. Any idea?

0 Kudos

852 Views
bobpaddock
Senior Contributor III

Sometimes the data sheet will state it in a table or footnote to table.
Sometimes they don't.

I do not know for this specific part.

Hopefully someone from NXP does.

 

0 Kudos

857 Views
bobpaddock
Senior Contributor III

Watch for if there are any issues with sector sizes.
Some Flash parts count a write to anyplace in the sector as a hit to the write endurance count for that sector.  Flash sector size of eight bytes would be rather unusual.

When such sectors fail they do not usually do it cleanly, so a simple read back of written value, does not really help.  That may pass because the gate charge is fresh, while a read at power cycling a month latter  or at a different temperature will fail, because the gate charge has dissipated due to the wear leakage.

You can get some ideas from this  EEPROM Hi-Rel counter:

https://www.microchip.com/content/dam/mchp/documents/OTH/ApplicationNotes/ApplicationNotes/01449A.pd...


0 Kudos