Hi,
I work with STM32F412ZG processor. I have also external LSE.
I have the next problem related to STOP mode.
There are some scenarios we want the processor to go to sleep for x hours.
The processor goes to sleep for 5 seconds, doing some job and return to sleep for 5 seconds and so on in infinite loop till it is broke by interrupt or if time elapsed( the x hours ).
The problem: from time to time the CPU is stuck at STOP MODE!!!
The next is a sample of the relevant code:
HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 5, RTC_WAKEUPCLOCK_CK_SPRE_16BITS) ;
RTC_TimeTypeDef sTimeBefore, sTimeAfter ;
RTC_DateTypeDef sDateBefore, sDateAfter ;
int sleepTime = 0 ;
int totalSleepTime = 0 ;
while(sleep) {
ReadRTC(&sTimeBefore, &sDateBefore); the HAL_RTC_GetDate function
HAL_PWR_EnterSTOPMode( PWR_LOWPOWERREGULATOR_ON , PWR_STOPENTRY_WFE ) ;
ReadRTC(&sTimeAfter, &sDateAfter);
sleepTime = CalculateSleepTime(sTimeBefore, sDateBefore, sTimeAfter, sDateAfter);
totalSleepTime += sleepTime;
if (totalSleepTime > x)
sleep = 0 ;
}
Please any assistance.
Shai
What I have tried:
To debug and found that the cpu is stuck