{
  "id": "embedded/rtos-tickless-idle-systick-missed",
  "signature": "FreeRTOS: tickless idle mode missed Systick interrupt, system clock drift detected",
  "signature_zh": "FreeRTOS：无滴答空闲模式错过系统滴答中断，检测到系统时钟漂移",
  "regex": "tickless idle mode missed Systick interrupt",
  "domain": "embedded",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "In tickless idle mode, the MCU enters a deep sleep state and the Systick timer is stopped; if the wake-up source (e.g., RTC or external interrupt) triggers too late or the sleep exit time is longer than expected, the next Systick interrupt is missed, causing the system tick count to drift.",
  "root_cause_type": "generic",
  "root_cause_zh": "在无滴答空闲模式下，MCU进入深度睡眠状态且系统滴答定时器停止；若唤醒源（如RTC或外部中断）触发过晚或退出睡眠时间超出预期，则下一个系统滴答中断被错过，导致系统滴答计数漂移。",
  "versions": [],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Disabling tickless idle entirely (configUSE_TICKLESS_IDLE = 0) increases power consumption but does not fix the underlying issue of Systick wake-up timing.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Increasing the Systick interrupt priority does not prevent the miss because the issue is timing, not priority inversion.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Implement a correction algorithm in the portSUPPRESS_TICKS_AND_SLEEP() macro. Example: #define portSUPPRESS_TICKS_AND_SLEEP(xExpectedIdleTime) \\ do { \\     uint32_t ulSysTickCount = SysTick->VAL; \\     if (xExpectedIdleTime > 100) { \\         // Enter sleep with RTC wake-up \\         HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, xExpectedIdleTime - 1, RTC_WAKEUPCLOCK_RTCCLK_DIV16); \\         __WFI(); \\         // Recalculate missed ticks \\         xExpectedIdleTime = (xExpectedIdleTime - (ulSysTickCount - SysTick->VAL) / (SystemCoreClock / 1000)); \\     } \\ } while(0)",
      "success_rate": 0.8,
      "how": "Implement a correction algorithm in the portSUPPRESS_TICKS_AND_SLEEP() macro. Example: #define portSUPPRESS_TICKS_AND_SLEEP(xExpectedIdleTime) \\ do { \\     uint32_t ulSysTickCount = SysTick->VAL; \\     if (xExpectedIdleTime > 100) { \\         // Enter sleep with RTC wake-up \\         HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, xExpectedIdleTime - 1, RTC_WAKEUPCLOCK_RTCCLK_DIV16); \\         __WFI(); \\         // Recalculate missed ticks \\         xExpectedIdleTime = (xExpectedIdleTime - (ulSysTickCount - SysTick->VAL) / (SystemCoreClock / 1000)); \\     } \\ } while(0)",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a dedicated low-power timer (LPTIM) as the wake-up source instead of the RTC, which provides finer granularity and reduces drift.",
      "success_rate": 0.85,
      "how": "Use a dedicated low-power timer (LPTIM) as the wake-up source instead of the RTC, which provides finer granularity and reduces drift.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Implement a correction algorithm in the portSUPPRESS_TICKS_AND_SLEEP() macro. Example: #define portSUPPRESS_TICKS_AND_SLEEP(xExpectedIdleTime) \\ do { \\     uint32_t ulSysTickCount = SysTick->VAL; \\     if (xExpectedIdleTime > 100) { \\         // Enter sleep with RTC wake-up \\         HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, xExpectedIdleTime - 1, RTC_WAKEUPCLOCK_RTCCLK_DIV16); \\         __WFI(); \\         // Recalculate missed ticks \\         xExpectedIdleTime = (xExpectedIdleTime - (ulSysTickCount - SysTick->VAL) / (SystemCoreClock / 1000)); \\     } \\ } while(0)",
    "Use a dedicated low-power timer (LPTIM) as the wake-up source instead of the RTC, which provides finer granularity and reduces drift."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.freertos.org/Documentation/RTOS_book.html",
  "official_doc_section": null,
  "error_code": "configUSE_TICKLESS_IDLE",
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.75,
  "resolvable": "true",
  "first_seen": "2024-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}