cancel
Showing results for 
Search instead for 
Did you mean: 

Variable Store In Memory

AJeth.2
Associate II

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.

4 REPLIES 4
Pierre_Paris
ST Employee

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.
Evangelist III
JPeac.1
Senior

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

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

JW