STM32H743: Backup RAM not saved
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
