Hello,
I think I found out a "feature" of the flash that I need to design for, but I want to get confirmation on it prior to actually implementing this to make sure I'm correct about it.
For our application, we have segmented one 8kB block out as "GP Flash" where we can write our firmware version, keep track of device specific information, and backup our RTC value (among other things). Well, in attempting to do the last of those operations and save the RTC value on demand, overwriting a Flash location with the updated RTC seconds value, I noticed that the operation continually fails, but only if I do not erase the block first. Meanwhile, in our flash initialization routine, we are easily able to read/erase/write the same flash location.
More technical detail, when I attempt to backup and overwrite the value, it returns from the flash write with FAPI_STATUS_FSM_ERROR. Digging into this further, I found that the FMSTAT register held a value of 0x00000030 (INVDAT | CSTAT). On other posts across the forum, these values have meant that the "data needs to be erased before reprogrammed."
Is this also the case for the CC2642R? Do I need to read/erase/write every single time I want to update a value in the block I have segmented for general purposes?
The only notation I see in the reference manual is about "a maximum of 83 write operations within a row between erases."
Is this assuming that each write is done on already erased flash?
Another thing from the data sheet: "Supported flash erase cycles before failure, single sector = 60k." So if we are trying to backup the RTC once an hour, we will have erased 60k times in less than 7 years, not counting any other erasure causes on that entire block.
Does this make sense? Do I also need to write a wear-leveling algorithm so we don't kill the flash with erase cycles?
Regards,
Tyler Witt