cancel
Showing results for 
Search instead for 
Did you mean: 

Does the STM32F407ZET6 have a persistent register mapped into memory?

gmmo
Associate II

I am currently working with the MCU STM32F407ZET6 used in an embedded device. I am relatively new to this MCU, but I'd like to know if there is a persistent register that I can write some 32-bit value to it and it does not get erased if the MCU is turned off. Is there one? If so how do I write to it? Any reference manual and/or sample code?

My problem is that during stress tests of our device, sometimes after several hours the MCU crashes. But our current software must turn on and off the MCU constantly and we are limited with logs. So when the device crashes in the middle of the night for example, after few minutes it is turned off. So I have no logs and left in the woods to find out what has happened.

If there is a register mapped into memory that I can poke a value there and next time it reboots I could read from it, it would be very helpful.

This MCU has the flash memory, but it is too slow. These crashes happen fast and I have no time to erase and re-program flash with logs. This is why I thought a persistent register could be quite useful.

and leads or help is greatly appreciated.

thank you.

10 REPLIES 10

Should by 4KB of NVRAM (BKPRAM)

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
gmmo
Associate II

Did not understand your answer. Can you elaborate more?

thank you.

It's a battery-backup RAM. Search for "BKPSRAM" in RM0090.

You can also use the RTC backup registers (RTC_BKPxR).

JW

Pavel A.
Evangelist III

The backup RAM and RTC need a battery, else it won't survive power-off.

If there's no battery, you can feed it from same power source as for the MCU itself, but it should remain always connected.

-- pa

Pavel A.
Evangelist III

The backup RAM and RTC need a battery, else it won't survive power-off.

If there's no battery, you can feed it from same power source as for the MCU itself, but it should remain always connected.

-- pa

gmmo
Associate II

Do you have some sample code showing how to write to that RAM? I looked at the manual and it looks like it mapped to 0x40024000.

#define BKPSRAM_BASE     ((uint32_t)0x40024000) /*!< Backup SRAM(4 KB) base address in the alias region             */

Though, when I tried to write to that piece of memory, it did not work. Below is what I have tried:

  size_t *pBase = (size_t *)BKPSRAM_BASE;

  printf ("BEFORE:%x\n", (int)*pBase);

  *pBase = 0xDEADBEEF;

  printf ("AFTER:%x\n", (int)*pBase);

my output:

BEFORE:0

AFTER:0

thank you!

 /* Enable BKPRAM Clock */

 __HAL_RCC_BKPSRAM_CLK_ENABLE();

 /* Enable the Backup SRAM low power Regulator */

 HAL_PWREx_EnableBkUpReg();

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
T J
Lead

use the flash chip, connected to SPI.

I use this one, cheap enough: AT25DN256

https://www.digikey.com/product-detail/en/adesto-technologies/AT25DN256-SSHF-T/1265-1120-2-ND/4702533

gmmo
Associate II

Looks like there are a lot more setup. I tired this and it worked:

https://stackoverflow.com/questions/20667754/how-to-use-backup-sram-as-eeprom-in-stm32f4

anything else I need to do?