3
\$\begingroup\$

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.

\$\endgroup\$
  • 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\$ – Chris Stratton Jan 31 '14 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\$ – Spehro Pefhany Feb 1 '14 at 4:27
6
\$\begingroup\$

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

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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