Question
STM32H745XI : Data from Backup SRAM getting lost on power cycle
I'm trying to use the 4K backup RAM on the STM32H745XI. Using following code initialize RTC and backup domain. VBAT of 3V coin cell is used power RTC backup domain on VDD off.
HAL_PWR_EnableBkUpAccess();
while ((PWR->CR1 & PWR_CR1_DBP) == RESET)
{
}
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_HIGH);
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
/*
*/
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
MX_RTC_Init();
__HAL_RCC_BKPRAM_CLK_ENABLE();
if(!HAL_PWREx_EnableBkUpReg())
{
printf("Backup SRAM ready\r\n");
}
}
following code is used to read and write
// write to backup RAM
memcpy(*(__IO uint8_t *)D3_BKPSRAM_BASE,(uint8_t *)&w_data, sizeof(w_data));
//read from backup RAM
memcpy(*(__IO uint8_t *)D3_BKPSRAM_BASE,(uint8_t *)&r_data, sizeof(r_data));
The RTC is working and keeps time even on power off and restart, 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.
No RDP or temper detection is enabled in my case.
