2025-12-09 10:58 AM - edited 2025-12-09 10:59 AM
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)
.
.
.
.