Skip to main content
HMucc.1
Associate
Nov 25, 2020 11:41 AM UTC
Solved

Having Problems activating SysTick after Stop mode

I'm using STM32F070CBT at 8mhz with almost all pins active (used for GPIOs, PWM, SPI,I2C,etc) , i'm using a timer to enter stop mode with low power regulator and waking up using GPIO external event, after waking up i checked that PWMs and GPIOs are still working but SysTick seems to have stopped as all delay functions enter a infinite loop on HAL_GetTick inside the delay function and SysTick_Handler is not being called anymore (i tested that using breakpoints) , i tried to activate SysTick again using :

  • Hal_Init();
  • HAL_ResumeTick();
  • HAL_InitTick(0);
  • SysTick->CTRL=0b011;

also tried to set SysTick priority to 0, also tried to recall "SystemClock_Config();" alongside SysTick activate function but it didn't work too , does anybody know what i need to do in order to re-activate SysTick?

This topic has been closed for replies.
HMucc.1
HMucc.1Best answer
Associate
Nov 25, 2020 5:18 PM UTC

-Solved -

Nobody writed a single reply, but i still think it's important to say it if anybody has the same issues, after waking up from Stop mode (which was being called in the interrupt of a timer) , i observed that SysTick Handler was still working and dind't need to be initialized again, but was bugging when i called delay instantly after waking up, so i set one flag and called it using "extern int TickStart" inside the SysTick Handler, and made it count until 9 (which kinda made a 9ms delay using SysTick Handler) , and after that i called the functions i needed outside of that timer interrupt and they worked (HAL_Delay and all functions that use it) , i just observed that the clock was a little different than configured so i needed to call "  SystemClock_Config();" just after waking up and that solved all my code problems.

3 replies

HMucc.1
HMucc.1Author
Associate
Nov 25, 2020 12:24 PM UTC

Correction : I checked systick handler (before using delay) and it is indeed entering the breakpoint, but when i call a single HAL_GetTick(); which is the function inside delay it enters a infinite loop and stops entering SysTick Handler

HMucc.1
HMucc.1AuthorBest answer
Associate
Nov 25, 2020 5:18 PM UTC

-Solved -

Nobody writed a single reply, but i still think it's important to say it if anybody has the same issues, after waking up from Stop mode (which was being called in the interrupt of a timer) , i observed that SysTick Handler was still working and dind't need to be initialized again, but was bugging when i called delay instantly after waking up, so i set one flag and called it using "extern int TickStart" inside the SysTick Handler, and made it count until 9 (which kinda made a 9ms delay using SysTick Handler) , and after that i called the functions i needed outside of that timer interrupt and they worked (HAL_Delay and all functions that use it) , i just observed that the clock was a little different than configured so i needed to call "  SystemClock_Config();" just after waking up and that solved all my code problems.

Explorer II
Feb 24, 2025 3:03 PM UTC

Just to contribute with some more information in case this is what's happening. From the Reference Manual RM0360, under 6. Power Control > 6.3 Low-power modes > 6.3.4 Stop mode > Exiting Stop mode:

When exiting Stop mode by issuing an interrupt or a wake-up event, the HSI oscillator is selected as system clock.

That probably explains your issue with changing clock and need to reconfigure again. Depending on the previous selected source / preescalers, speed and thus reload value for timeout may not match.