Skip to main content
Visitor II
September 17, 2024
Question

STM32F412ZG stuck at STOP Mode

  • September 17, 2024
  • 1 reply
  • 1511 views

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

    This topic has been closed for replies.

    1 reply

    Technical Moderator
    September 20, 2024

    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

    Shush1908Author
    Visitor II
    September 25, 2024

    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

    Shush1908Author
    Visitor II
    September 25, 2024

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