I want to be able to store values in a non-volatile memory so that the microcontroller can load these settings at start up. These settings might change at run-time and it is important for the systems functionality that these settings are stored.

As far as I know the only non-volatile memory on the STM32F103 is the flash. Is it possible to save values on flash someplace at run-time?

I also have the possibility to use a SD card and the SDIO or SPI interface to store the values there, but if possible it would be best if a SD card can be avoided.

The amount of data is only a few hundred bytes at most.

  • 2
    \$\begingroup\$ Yes, you can write to the flash, subject to the usual constraints of erase block size, limited rewrite life, and it being a relative slow and tricky operation. ST has an app note describing how. Additionally, some SWD-based flashing tools actually work by loading each block of data to RAM and then running a small program which stores that to flash. \$\endgroup\$ Jan 31, 2014 at 23:26
  • 1
    \$\begingroup\$ A small serial EEPROM is sometimes a better solution. You can get SPI or I2C or Microwire versions, in SOIC-8 and even SOT-23 packages. \$\endgroup\$ Feb 1, 2014 at 4:27

1 Answer 1


From what i know there are two options:

  • Use flash (emulated as EEPROM for ease of use) according to this Appnote
  • Use the backup registers (20 byte of battery backed registers) according to the Reference Manual Pages 67 And 79

By The Way if the you move one of the bigger brothers (F2-F4) of this chip you get a whole part of ram battery backed something like 4k but it depends on the actual chip


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.