Skip to main content
JGeis
Visitor II
September 27, 2018
Question

STM32L051 EEPROM initialisation

  • September 27, 2018
  • 1 reply
  • 793 views

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

    This topic has been closed for replies.

    1 reply

    Tesla DeLorean
    Guru
    September 27, 2018

    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 VenmoUp vote any posts that you find helpful, it shows what's working..