2019-11-09 04:36 AM
I'm trying to use the 4K backup RAM on the STM32H743. The RTC is working and keeps time so I know the battery system is OK. I can read and write to the backup RAM OK but it loses all data on power off.
I've enabled access as follows:
HAL_PWREx_EnableBkUpReg();
HAL_PWR_EnableBkUpAccess();
The code behind these is trivial
SET_BIT(PWR->CR1, PWR_CR1_DBP);
and
SET_BIT(PWR->CR2 PWR_CR2_BREN);
The C source for stm32h7xx_hal_pwr.c has the following comment:
" After reset, the backup domain (RTC registers, RTC backup data
registers and backup SRAM) is protected against possible unwanted
write accesses.
To enable access to the RTC Domain and RTC registers, proceed as follows:
(+) Enable the Power Controller (PWR) APB1 interface clock using the
__HAL_RCC_PWR_CLK_ENABLE() macro.
(+) Enable access to RTC domain using the HAL_PWR_EnableBkUpAccess() function.
"
but __HAL_RCC_PWR_CLK_ENABLE() does not exist for the H7 and looking at the reference manual there is no obvious bit to set in the clock enable registers. There is a relevant bit on the F4 and the two commands do different things on the F4 but of course the registers have completely different names
*(__IO uint32_t *) CSR_BRE_BB = (uint32_t)ENABLE;
*(__IO uint32_t *) CR_DBP_BB = (uint32_t)ENABLE;
Any help appreciated
Solved! Go to Solution.
2023-06-22 01:32 AM
I am also facing same issue.
VBAT connection is proper as I am able to retrieve data and time in backup register.
Tamper detection is disabled.
RDP is also not used.
2023-06-22 02:51 AM
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWR_EnableBkUpAccess();
__HAL_RCC_BKPRAM_CLK_ENABLE();
// Enable backup regulator
HAL_PWREx_EnableBkUpReg();
// Wait until backup regulator is initialized
while (!LL_PWR_IsActiveFlag_BRR());
I have used above methods to initialization of Backup domain.
On VDD I am able to read and write on SRAM successfully and even on soft reset data is not lost.
but when device goes into power down (VBAT connected to RTC) data is lost when checked on next power cycle.
RDP, temper detection and cache is disabled.
2023-06-22 04:22 AM
Please don't hijack other's threads.
Start your own thread, perhaps giving link to this one; stating the STM32 model you are using, what hardware/board (Disco/Nucleo/your own) are you using, what is the VBAT connection, and how exactly do you arrive at the problem you are describing.
JW