cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L051 EEPROM initialisation

JGeis
Associate

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};

1 REPLY 1

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.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..