2018-09-26 11:25 PM
Is it possible to initialize the EEPROM area of a STM32L051 with values at compile time (IAR compiler) simply like this:
const char array[] @ "my_eeprom" = {0X1C,0X1F,0X9F,0XFF};
2018-09-27 06:00 AM
Yes, but one needs to be careful. The linker script (.ICF) can define areas, and data that gets into the .HEX will be written there.
The other approach is to have a routine that checks if EEPROM content is present, and valid, and if not loads defaults, and saves them back to EEPROM. My approach is to have an array/structure with settings held in RAM, code uses these values, and flags if it changes them, and I have specific routines to read/write out of EEPROM when appropriate. This helps portability in systems where NV is slow, has limited write cycles, and might not play well with normal code execution.