How can i store data in flash memory?
I would like to store some (small) data in between runs (like parameter data entered via potmeters and such)
i found:
int flash_ProgramWord(uint32_t Address, uint32_t Data)
I guess that's what I need, the only question is what address to use...
Storing data in flash
I believe Sector 10 - 0x080C0000 - 0x080DFFFF (128 Kbytes) is still free.
Be sure to erase it first (only whole sectors can be erased).
Also, the number of flash program/erase cycles is limited. Not an issue if you use it infrequently, but for frequent writing a "virtual eeprom" scheme is interesting.
Successive write operations are possible without the need of an erase operation when changing bits from ‘1’ to ‘0’. Writing ‘1’ requires a Flash memory erase operation.
So the first words can be used to indicate the current location of user data. When new data needs to be written, the actual location can be incremented, and an additional zero written to the first words, avoiding frequent sector erases.
Thanks I will have a look. Maybe it would be best to create an object that could be shared between patches to avoid having different objects overwriting each others data. I'm not sure how the interface for this would look though.
Do you have any idea how many write/erase cycles we can expect from the flash?
Perhaps storing the data on sdcard would be better, even though that probably has the same problem, at least it can be swapped out for another card.
10.000 cycles at TA = –40 to +85 °C
SDCard will have a similar problem. SDCards can do wear leveling, still I do not expect much better results. Typical sdcard applications do not require over 1000 erase cycles.
Still, I'd recommend storing patch data on sdcard, to avoid interference between patches.