This is one of the very few occasions where I use global variables. The revision counter can also be used to implement a highly reliable two-bank storage protocol that always keeps a single valid copy of all settings, to protect against power failures in the middle of a write operation.īesides the structure definition the interface exposes two functions (one to load and another to store the settings) and a global pointer to the structure. ![]() There is also a revision counter that is incremented every time to keep track how many times the EEPROM was written. ![]() The structure is verified using CRC32 checksum that is placed at the end. It was tested on an STM32L151RC.Įverything starts with a definition of a structure that will hold all the parameters, flags and settings. I wrote a generic driver for keeping settings in the EEPROM based on the standard peripherals library for STM32L, that is easier to understand than the official demos from ST. This may come handy during application updating, as whole flash can be simply erased without affecting the EEPROM. Regular flash (that stores code) can also be used, but the EEPROM can be updated byte-by-byte and is independent from regular flash. It is useful for storing settings or calibration data. ![]() Most STM32 microcontrollers feature an internal EEPROM.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |