|Top Previous Next|
STG library automatically allocates the storage for settings. That is, non-volatile and volatile memory addresses where individual settings are stored are calculated automatically.
When non-volatile settings are stored in the EEPROM (default configuration), they are located at the bottom of the EEPROM, right after the special configuration area.
When the Custom RAM option is not selected, the volatile (RAM) settings are stored in an array which is maintained by the library (stg_ram_array variable).
When the Custom RAM option is checked, the volatile (RAM) settings are stored using callback_stg_vm_read() and callback-stg_vm_write(), which should contain custom code for accessing whatever memory you have decided to use for storing volatile settings (example: internal memory of a real-time clock IC).
When the Redundancy option is set to two copies for non-volatile settings, the library maintains a second copy of data for non-volatile settings (this doubles the required amount of non-volatile memory) and keeps a single copy for volatile settings. When the Redundancy option is set to two copies for ALL settings, even volatile settings are stored as two independent copies.
Two copies of setting data are stored like this:
Bottom of EEPROM (flash)
Bottom of RAM
Each setting is stored in the following format:
*Only when the Timestamp option is enabled.
The checksum is a 255 complement of the modulo 256 (8-bit) sum of all data bytes for the setting except the checksum itself. The amount of storage allocated for setting data depends on this setting's properties. The total amount of memory taken by the setting can't exceed 255 bytes.
Setting data includes one or more setting members depending on the number of members in this setting.
Setting data field for a setting with three members
Here is how member data for settings of different types is stored: