Skip to main content
Graduate II
December 9, 2025
Question

FreeRTOS tickless mode - ulExpectedIdleTime and HAL_SuspendTick() Problem in STM32H7

  • December 9, 2025
  • 1 reply
  • 97 views

Hi everyone,

I tried implementing tickless idle on my STM32H7 CM7 core following a tutorial I found: https://www.youtube.com/watch?v=hVlpf1Rm4Qo

I suspended the tick (TIM6) and set up LPTIM as the wakeup source.

However, I noticed that my core wakes up every 41 ticks, even though my ONLY task is delayed by 2000 ticks. It seems like the core is being woken up prematurely, and ulExpectedIdleTime is only 41 instead of 2000.

Does anyone know why tickless idle is not sleeping for the full expected duration, or what could be causing these frequent wakeups despite SysTick being disabled?

Pre Sleep fuction:

__weak void PreSleepProcessing(uint32_t ulExpectedIdleTime) {
	/* place for user code */
	HAL_GPIO_WritePin(LED_1_GPIO_Port, LED_1_Pin, GPIO_PIN_SET);

	//printf("[CM7][PreSleepProcessing]entered PreSleepProcessing!\r\n");
	HAL_SuspendTick(); //suspend SysTick Timer
	HAL_LPTIM_TimeOut_Start_IT(&hlptim1, 0xFFFF, ulExpectedIdleTime); // enable interrupt from low power timer
}

And Post function:

__weak void PostSleepProcessing(uint32_t ulExpectedIdleTime) {
	/* place for user code */
	actual_sleep_ticks = HAL_LPTIM_ReadCounter(&hlptim1);

	HAL_LPTIM_TimeOut_Stop_IT(&hlptim1);
	HAL_ResumeTick();
	HAL_GPIO_WritePin(LED_1_GPIO_Port, LED_1_Pin, GPIO_PIN_RESET);
	uint32_t time_ms = (actual_sleep_ticks * 1000) / 32768;

	printf(
			"[CM7] Planned ticks: %lu ticks, sleep ticks: %lu tikow LPTIM (%lu ms)\r\n",
			ulExpectedIdleTime, actual_sleep_ticks, time_ms);
	//printf("[CM7][PostSleepProcessing]Exit PostSleepProcessing!\r\n");
}

 Task:

void StartDefaultTask(void *argument)
{
 /* USER CODE BEGIN StartDefaultTask */
 /* Infinite loop */
 for(;;)
 {
 osDelay(2000);
	HAL_GPIO_TogglePin(LED_2_GPIO_Port, LED_2_Pin);
 }
 /* USER CODE END StartDefaultTask */
}

And program output:

##################################################Starting RTOS Core 1##################################################

[CM7][PreSleepProcessing]entered PreSleepProcessing!
[CM7] Planned ticks: 41 ticks, sleep ticks: 0 tikow LPTIM (0 ms)
[CM7][PreSleepProcessing]entered PreSleepProcessing!
[CM7] Planned ticks: 41 ticks, sleep ticks: 0 tikow LPTIM (0 ms)
[CM7][PreSleepProcessing]entered PreSleepProcessing!
[CM7] Planned ticks: 41 ticks, sleep ticks: 0 tikow LPTIM (0 ms)
[CM7][PreSleepProcessing]entered PreSleepProcessing!
[CM7] Planned ticks: 41 ticks, sleep ticks: 0 tikow LPTIM (0 ms)
[CM7][PreSleepProcessing]entered PreSleepProcessing!
[CM7] Planned ticks: 41 ticks, sleep ticks: 0 tikow LPTIM (0 ms)
[CM7][PreSleepProcessing]entered PreSleepProcessing!
[CM7] Planned ticks: 41 ticks, sleep ticks: 0 tikow LPTIM (0 ms)
[CM7][PreSleepProcessing]entered PreSleepProcessing!
[CM7] Planned ticks: 41 ticks, sleep ticks: 0 tikow LPTIM (0 ms)
[CM7][PreSleepProcessing]entered PreSleepProcessing!
[CM7] Planned ticks: 41 ticks, sleep ticks: 0 tikow LPTIM (0 ms)

.

.

.

.

    This topic has been closed for replies.

    1 reply

    ST Employee
    December 15, 2025

    Hello @Patryk_Kucia ,

    To solve your issue with frequent wake-ups  in tickless idle mode, I recommend you check one key point:

    Check the value of configEXPECTED_IDLE_TIME_BEFORE_SLEEP in your FreeRTOSConfig.h file.
    This parameter sets the maximum time the system is allowed to stay in tickless mode. If it’s set to a low value (for example, 41), your MCU will not sleep for longer periods, even if your tasks are delayed by more ticks. Try increasing this value according to the needs of your application.

    Often, this configuration setting is the main reason for shorter-than-expected sleep durations.

    Regards,

    Maher