# SysTick：中断在翻转周期内未得到服务，时间基准损坏

- **ID:** `embedded/arm-systick-rollover-missed`
- **领域:** embedded
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

SysTick中断被更高优先级的中断服务程序屏蔽或延迟，导致24位计数器未执行处理程序就翻转，损坏了RTOS滴答计数。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| FreeRTOS v10.6.0 | active | — | — |
| ARM Cortex-M4 r0p1 | active | — | — |
| STM32CubeH7 v1.11.0 | active | — | — |

## 解决方案

1. ```
   Ensure SysTick interrupt priority is lower than time-critical ISRs but never masked for longer than 1 SysTick period. In FreeRTOS, set configMAX_SYSCALL_INTERRUPT_PRIORITY to include SysTick and check that no ISR runs for > 1 ms (assuming 1 kHz tick).
   ```
2. ```
   Add a guard to detect missed tick and manually increment RTOS tick count. Implement a high-priority timer that checks if SysTick counter wrapped without ISR.
   ```
3. ```
   Reduce interrupt latency by splitting long ISRs into deferred tasks (e.g., using FreeRTOS task notifications or semaphores).
   ```

## 无效尝试

- **Increase SysTick interrupt priority to 0 (highest)** — Setting SysTick to highest priority may break critical timing in other interrupts and does not address the root cause of long ISR masking. (60% 失败率)
- **Disable all other interrupts to ensure SysTick runs** — Disabling interrupts globally defeats the purpose of RTOS and can cause watchdog resets or data loss. (70% 失败率)
- **Increase SysTick reload value to extend rollover period** — SysTick reload is fixed at 24 bits (max 16,777,215 cycles); increasing it is impossible without changing clock source. (90% 失败率)
