Is it expected for the PWR_CR1_DBP bit to be disabled on STM32WLE5 during STOP2?
I am using the STM32WLE5, and periodically entering and exiting STOP2 mode. The VBAT is connected directly to VCC. I set PWR_CR1_DBP on system initialization, and assume it should not change. On exiting stop mode, sometimes the DBP bit is randomly cleared - causing subsequent writes to the RTC to fail.
My code below is my stop mode entry routine, and I observe the DBP bit being cleared directly after stop mode. Note I have disable IRQ's to eliminate the possibly of this being cleared during an ISR.
void CORE_Stop(void)
{
CRITICAL_SECTION_BEGIN();
HAL_SuspendTick();
MODIFY_REG(PWR->CR1, PWR_CR1_LPMS, PWR_LOWPOWERMODE_STOP2);
SET_BIT(SCB->SCR, SCB_SCR_SLEEPDEEP_Msk);
if (!(PWR->CR1 & PWR_CR1_DBP))
{
// This never occurrs
__BKPT();
}
__WFI();
if (!(PWR->CR1 & PWR_CR1_DBP))
{
// This seems to occurr randomly
__BKPT();
}
CLEAR_BIT(SCB->SCR, SCB_SCR_SLEEPDEEP_Msk);
CLK_InitSYSCLK(); // Equivilent to SystemClockConfig
HAL_ResumeTick();
CRITICAL_SECTION_END();
}A workaround is obvious - but my question is whether this behavior is expected. It appears to be undocumented.
Is this indicative of some other hardware/firmware issues?