The STM32F2/F4 microcontrollers provide a backup domain that includes 4 Kbytes of backup SRAM. This region can be considered as an internal EEPROM when VBAT is present: its content is preserved upon reset if VBAT is connected. This means that it can be used as a safe-guard memory (SGM).
:information_source: INFO :information_source: *Of course you can connect VBAT to the board's power supply, but it would not provide the same reliability level as having a backup battery or a different power supply.*
> :information_source: **INFO: Of course you can connect VBAT to the board's power supply, but it would not provide the same reliability level as having a backup battery or a different power supply.**
The backup region also includes twenty 32-bit registers that can be used store a total of 80 bytes (word-aligned). Backup registers are not reset by a system, a power reset, or when the device wakes up from the standby mode.
...
...
@@ -17,7 +17,7 @@ Moreover, after a reset, the backup domain is protected against possible unwante
The Miosix SGM driver constructor prepares the backup domain for you: it enables the backup clock and disables the write protection. It also retrieves the last board reset reason.
Please remember that the backup domain content is wiped by the driver if, after the reset, the `RCC_CSR_SFTRSTF` (i.e. software reset) flag is not set in the `RCC->CSR` register.
⚠️ WARNING ⚠️ *Notice that more than one flag could be set at the same time in the `RCC->CSR` register!*
> :warning: **WARNING: Notice that more than one flag could be set at the same time in the `RCC->CSR` register!**
After enabling it, in order to read/write from/to the backup domain, you can simply use pointers or standard C/C++ functions, such as `memcpy` (better performance), starting from the backup region base address, which is `BKPSRAM_BASE`.