Skip to main content
AJeth.2
Associate
July 16, 2023
Question

Variable Store In Memory

  • July 16, 2023
  • 4 replies
  • 1549 views

Hello

I want to update my variable continuously on Memory, so whenever bootup and power loss I can read that Value.

So which is the best way to store variable and read when MCU bootup.

This topic has been closed for replies.

4 replies

Pierre_Paris
ST Employee
October 18, 2023

Hello @AJeth.2,

The best option is to store your variable in the main flash because it's a non-volatile memory BUT

  • In case of power on, the embedded flash memory automatically loads the option bytes. During the option bytes loading sequence, the device remains under reset and the embedded flash memory can’t be accessed. The values on the BOOT pin are latched on the 4th rising edge of SYSCLK after reset release and then the boot mode configuration is resolved.
  • In case of power loss,  the CPU is turned OFF and cannot access any memory... Do you want to read it with an external component ? However, 5 32-bit backup registers are retained in all low-power modes and also in VBAT mode. In fact, the backup registers (TAMP_BKPxR) are implemented in the RTC domain that
    remains powered-on by VBAT when the VDD power is switched off.

Best Regards,

Pierre

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Pavel A.
Super User
October 18, 2023
JPeac.1
Visitor II
October 18, 2023

If you have a battery backup for the RTC you can use the general purpose data registers (I believe there are 20 bytes in the G0 series) to save a few variables across resets and power loss.

  Jack Peacock

waclawek.jan
Super User
October 18, 2023

You've meant the Backup registers, I presume, TAMP_BKPxR.

JW