cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F405 BKPSRAM Random values after initialize

Jan Wustrau
Associate II

Hello,

I have a strange issue with backup ram in F405. It is battery powered after main power off.

When i remove battery and power up board, whole bkpram contains values of 0 - this is normal. But after initialize procedure whole memory contains random values.

This is very strange, because during normal work (with battery connected) i can write data to it, switch power off and all my data remains after next power up.

It's my initialize function:

 

	RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_BKPSRAM, ENABLE);
	PWR_BackupAccessCmd(ENABLE);
	PWR_BackupRegulatorCmd(ENABLE);

	while ((PWR->CSR & (PWR_FLAG_BRR)) == 0);

 

2 REPLIES 2

> When i remove battery and power up board, whole bkpram contains values of 0 - this is normal.

No. The backup-domain reset does not clear BKPSRAM, see RM. Power removal (i.e. both VBAT and VDD) and restore brings the BKPSRAM up with random content.

What you see as all zeros is consequence of the BKPSRAM not having clock enabled in RCC.

You can try it yourself: with the battery installed and BKPSRAM properly initialized and filled up with your data, disable is clock in RCC and try to read it. Then reenable the clock and try to read it again. You don't need to write code for this, you can experiment in debugger. 

JW

Jan Wustrau
Associate II

Thank you for your explanation.

My test was by uploading firmware with a while(1); before initialization so that after VBAT and VDD reset, the program wouldn't execute anything.
So, I understand that in such a case (as long as the firmware doesn't enable the clock), neither the STM32CubeIDE debugger nor ST-Link (with STM32CubeProgrammer) are not able to read that memory?

 

I have one more question. What is the reason (probably physical) that this memory gets a random values after a power loss?