Skip to main content
Raider E
Associate III
May 29, 2017
Question

how can I store something in a non volatile memory, any simple example to start with ?

  • May 29, 2017
  • 1 reply
  • 669 views
Posted on May 29, 2017 at 02:55

I just would like to store one or two values in the in a non volatile memory and not sure how to do it.any ideas or a an example to start with.

Many thanks

    This topic has been closed for replies.

    1 reply

    Zt Liu
    Senior III
    May 31, 2017
    Posted on May 31, 2017 at 16:38

    hi, Raider!

    You may first decide whether your data will be placed in flash or eeprom(if any).

    For example, 

    I have a STM32L011 on my desk, 

    there are 512 bytes of eeprom.

    I may use following code to write and read eeprom, using cubeMX

    static uint32_t eepromData;

    HAL_FLASHEx_DATAEEPROM_Unlock();

    //write eeprom

    HAL_FLASHEx_DATAEEPROM_Program(FLASH_TYPEPROGRAM_WORD,DATA_EEPROM_BASE, 0x12345678);

    //read eeprom

    memcpy(&eepromData,(void*)DATA_EEPROM_BASE,sizeof(uint32_t));

    Similar examples are presented in CubeMx project examples in FLASH folder.

    Good Luck!

    Zt

    .