2021-06-07 06:01 AM
I am using STM32F091RCTx microcontroller and have configured RTC internal periodic wake up timer in interrupt mode. On timeout the respective isr routine is getting called but it is not waking up the MCU. i am not using SLEEP_ON_EXIT.
Can anyone help me knowing why it's happening ?
Thanks in advance
Tanuj
/* Application Code */
DEBUG_PRINT("<< Device Entering To Sleep >>\n");
configureUnusedPeripheralsForSleep();
/** Enable the WakeUp
*/
if (HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 20, RTC_WAKEUPCLOCK_CK_SPRE_16BITS) != HAL_OK)
{
Error_Handler();
}
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); // Going to sleep
configureAllPeripheralsAfterWakeup();
DEBUG_PRINT("<< Device Exiting From Sleep >>\n");
/* RTC Wake Up Timer Callback */
void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(hrtc);
/* NOTE : This function should not be modified, when the callback is needed,
the HAL_RTCEx_WakeUpTimerEventCallback could be implemented in the user file
*/
if (FALSE == wdg_checkForReset())
{
IWDG_ReloadCounter();
}
else
{
while(1);
}
}
2023-01-11 02:13 AM
Hello Tanuj @it@nuj,
Thank you for your question. I think the MCU woke up but is immediately reset by the IWDG or is reset during the stop mode because it is not refresh at the right time. As you may know, the IWDG is clocked from an independent 40 kHz internal RC and it operates independently from the main clock. That's why it can operate in Stop and Standby modes. Can you please share your STM32CubeMX setting of the IWDG & RTC? What are the reload/prescaler/window values ?
My advise is to enter in debug mode and add a breakpoint line 30 (or add a trace). Then, you can verify if the program run until this point. If not, there is a timing problem. The counter can be frozen in debug mode, so you need to relaunch the program under reset.
Regards,
Pierre
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.