Re: SST26VF032B flash memory issue.
2021/01/01 10:03:46
(permalink)
As the other posters have said, you have number of options
1) Do not store the sequence number on flash. Is there a reason for this? If you are trying to retain the last sequence number in the event of losing power, I would consider some type of reset procedure rather than storing in flash. I have a similar problem with one of my designs, and made it so sequence number zero reset the sequence count on both client and server.
2) If you really need to store the sequence number, how are you replacing the old sequence number with the new, erasing a page every time?
3) If you have no other options, google "wear leveling" to find algorithms. For you application, if you are erasing a page, then just use a different byte in the page for every write. The way this works is you will need to store a "valid" bit along with the sequence value, this bit needs to be a 1, because you can only change a 1 to a zero without erasing, not a zero to a 1. Them for the next sequence number, change the valid bit at the current location to a zero, increment to the next location, and write the next value with the valid bit set. I am not recommending this, I think you will still run into wear problems,