cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F412ZG stuck at STOP Mode

Shush1908
Associate II

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);// This function calls the HAL_RTC_GetTime function and after that
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

3 REPLIES 3
Imen.D
ST Employee

Hello @Shush1908 ,

Try to disable the Systick interrupt.

You can refer to the PWR_STOP example within STM32CubeF4:

STM32CubeF4/Projects/STM32F412G-Discovery/Examples/PWR/PWR_STOP at master · STMicroelectronics/STM32CubeF4 · GitHub

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

Hi,

Thanks for your reply.

I got hard fault from time to time ( it seems that we stuck in the STOP MODE) and also the sleep time calculation is not good(from time to time).

Shai

Of course after I add what you wrote: HAL_SuspendTick() and HAL_ResumeTick()