# Systick: timer underflow detected, system tick count corrupted

- **ID:** `embedded/arm-systick-timer-underflow`
- **Domain:** embedded
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

SysTick timer reload value set too low or clock divider misconfigured, causing counter to underflow before interrupt service routine can increment tick count.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| CMSIS 5.9.0 | active | — | — |
| FreeRTOS 10.4.6 | active | — | — |
| ARM Cortex-M4 r1p1 | active | — | — |

## Workarounds

1. **Set SysTick reload value to (SystemCoreClock / 1000) - 1 for 1ms tick, and ensure CLKSOURCE bit selects processor clock. Example: SysTick_Config(SystemCoreClock / 1000);** (92% success)
   ```
   Set SysTick reload value to (SystemCoreClock / 1000) - 1 for 1ms tick, and ensure CLKSOURCE bit selects processor clock. Example: SysTick_Config(SystemCoreClock / 1000);
   ```
2. **Add a guard in SysTick_Handler to check reload value: if (SysTick->LOAD == 0) { SysTick->LOAD = (SystemCoreClock / 1000) - 1; }** (85% success)
   ```
   Add a guard in SysTick_Handler to check reload value: if (SysTick->LOAD == 0) { SysTick->LOAD = (SystemCoreClock / 1000) - 1; }
   ```

## Dead Ends

- **** — Increasing SysTick interrupt priority does not fix the underflow, as the issue is timer reload value, not priority masking. (85% fail)
- **** — Adding more delay loops in main loop does not prevent timer underflow; the problem is deterministic and timing-independent. (90% fail)
