Skip to main content
VWied.1
Associate III
January 6, 2022
Solved

How to go into stop mode with FreeRTOS running on an STM32L073 board. HAL_SuspendTick() is not working while using FreeRTOS?

  • January 6, 2022
  • 2 replies
  • 2252 views

I am trying to use stop mode with the STM32L073 chip. I am able to get my code working while I am not using FreeRTOS on the STM32L073. I am also able to get this working on the STM32G0 Nucleo board with FreeRTOS.

When I start using FreeRTOS on the STM32L073, I am getting timer interrupts on the systick Timebase source I am using. TIM7 in this case.

I believe after reading up on this that HAL_SuspendTick() should be stopping all TIM7 interrupts on my system until I call HAL_ResumeTick();

 //Last community.st.com solution to deal with this problem was to only include the 2 interrupts of RTC and button interrupt. That is what this tempEXTIIMR value is.
 volatile uint32_t tempEXTIIMR = 0;
  tempEXTIIMR = EXTI->IMR;
 //Disable all but RTC wake up source and ON_OFF_BUTTON
 //EXTI_IMR_IM3 is the bitfield for the ON_OFF_BUTTON's interrupt
 EXTI->IMR = RTC_EXTI_LINE_WAKEUPTIMER_EVENT | EXTI_IMR_IM3;
 
 HAL_SuspendTick();
 osThreadSuspendAll();
 
 HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI);
 
 SystemClock_Config();
 HAL_ResumeTick();
 
 EXTI->IMR = tempEXTIIMR;
 
 HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);
 osThreadResumeAll();

This topic has been closed for replies.
Best answer by VWied.1

So I tried to recreate the issue. Now it works fine if I am debugging or not. I didn't change anything so that is a bit concerning...

2 replies

Walid ZRELLI
Visitor II
January 13, 2022

Hello @VWied.1​ 

Was this behavior observed during an active debugging session?

BeST Regards,

Walid

VWied.1
VWied.1AuthorBest answer
Associate III
January 13, 2022

So I tried to recreate the issue. Now it works fine if I am debugging or not. I didn't change anything so that is a bit concerning...