2024-06-27 08:55 AM
I am using STM32L0 with LSE rtc xtal, CubeMX/HAL. I have a 20 second wakup using
if (HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 40960, RTC_WAKEUPCLOCK_RTCCLK_DIV16) != HAL_OK)
{
Error_Handler();
}
AND
HAL_SuspendTick();
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
HAL_ResumeTick();
this works ok as long as I don't use //HAL_PWR_DisableBkUpAccess(); or it never enters stop mode
now I use HAL_PWR_EnterSTANDBYMode(); to shutdown the device but it wakes 20 seconds later.
so I tried adding
if (HAL_RTCEx_DeactivateWakeUpTimer(&hrtc) != HAL_OK)
{
ErrorHandler(ERR_ALARM_DEACT);
}
but the call returns HAL_RTC_STATE_TIMEOUT
Any ideas?
Solved! Go to Solution.
2024-07-01 12:55 AM
OK as none has commented here I will fill in the solution, it looks like I was calling
HAL_PWR_DisableBkUpAccess();
in another place I did not realise and this was stopping
(HAL_RTCEx_DeactivateWakeUpTimer(&hrtc) != HAL_OK)
from completing without error.
I find it strange that wakeup timer is dependant on backup register access being disabled, I would not expect this behavior and no note in the function header to inform users this is so.
"@note Ensure HAL_PWR_EnableBkUpAccess is called before this function" would be helpful.
2024-07-01 12:55 AM
OK as none has commented here I will fill in the solution, it looks like I was calling
HAL_PWR_DisableBkUpAccess();
in another place I did not realise and this was stopping
(HAL_RTCEx_DeactivateWakeUpTimer(&hrtc) != HAL_OK)
from completing without error.
I find it strange that wakeup timer is dependant on backup register access being disabled, I would not expect this behavior and no note in the function header to inform users this is so.
"@note Ensure HAL_PWR_EnableBkUpAccess is called before this function" would be helpful.