Bird
Raised Fist0
ARM Architectureknowledge~10 mins

SysTick timer for RTOS tick in ARM Architecture - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - SysTick timer for RTOS tick
SysTick Timer Configured
↓
Timer Counts Down
↓
Count Reaches Zero?
No→Continue Counting
Yes↓
Generate Interrupt
↓
RTOS Tick Handler Runs
↓
Update System Tick Count
↓
Schedule Tasks if Needed
↓
Reload Timer
↩Back to Timer Counts Down
The SysTick timer counts down from a set value, triggers an interrupt when it reaches zero, which runs the RTOS tick handler to update system time and manage task scheduling, then reloads to start counting again.
Execution Sample
ARM Architecture
SysTick->LOAD = 16000 - 1;
SysTick->VAL = 0;
SysTick->CTRL = ENABLE | TICKINT | CLKSOURCE;

// On interrupt:
RTOS_Tick_Handler();
Configures SysTick to generate an interrupt every 1 ms (assuming 16 MHz clock), then runs the RTOS tick handler on each interrupt.
Analysis Table
StepSysTick COUNTInterrupt?ActionRTOS Tick Count
116000NoCounting down0
28000NoCounting down0
31NoCounting down0
40YesInterrupt triggered0
5-YesRTOS Tick Handler runs1
615999NoTimer reloaded and counting1
78000NoCounting down1
80YesInterrupt triggered1
9-YesRTOS Tick Handler runs2
💡 Execution continues indefinitely as SysTick reloads and interrupts periodically to update RTOS ticks.
State Tracker
VariableStartAfter Step 4After Step 5After Step 6After Step 9
SysTick COUNT160000-159990
InterruptNoYesYesNoYes
RTOS Tick Count00112
Key Insights - 3 Insights
Why does the SysTick COUNT reset to 16000 after reaching zero?
Because after the interrupt triggers at zero (see Step 4), the timer is reloaded with the initial value (Step 6) to start counting down again.
When exactly does the RTOS Tick Count increase?
The RTOS Tick Count increases during the RTOS Tick Handler execution after the interrupt triggers (Step 5 and Step 9).
Does the SysTick timer stop after one interrupt?
No, the timer reloads automatically after each interrupt (Step 6), so it continues generating periodic interrupts.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the SysTick COUNT value when the first interrupt occurs?
A0
B1
C16000
D8000
💡 Hint
Check Step 4 in the execution_table where Interrupt? is Yes.
At which step does the RTOS Tick Count first increase?
AStep 6
BStep 4
CStep 5
DStep 3
💡 Hint
Look at the RTOS Tick Count column in execution_table between Step 4 and Step 5.
If the SysTick timer reload value was doubled, how would the counting steps change?
AInterrupts would happen twice as fast
BCounting steps would take twice as long before interrupt
CRTOS Tick Count would increase twice as fast
DNo change in timing
💡 Hint
Consider how the SysTick COUNT value relates to interrupt timing in the execution_table.
Concept Snapshot
SysTick timer counts down from a set reload value.
When it reaches zero, it triggers an interrupt.
Interrupt runs RTOS tick handler to update system tick count.
Timer reloads automatically to continue periodic interrupts.
Used to keep RTOS time and schedule tasks regularly.
Full Transcript
The SysTick timer is set with a reload value to count down from. It counts down each clock cycle until it reaches zero. When zero is reached, the timer triggers an interrupt. This interrupt runs the RTOS tick handler, which updates the system tick count used by the RTOS to manage time and task scheduling. After the interrupt, the timer reloads the initial value and starts counting down again. This cycle repeats indefinitely, providing a regular timing source for the RTOS tick. The execution table shows the countdown, interrupt triggering, and tick count updates step by step.

Practice

(1/5)
1. What is the main purpose of the SysTick timer in an RTOS?
easy
A. To generate regular interrupts for task switching
B. To increase CPU clock speed
C. To store data temporarily
D. To manage memory allocation

Solution

  1. Step 1: Understand SysTick timer role

    The SysTick timer is designed to create periodic interrupts.
  2. Step 2: Connect interrupts to RTOS function

    These interrupts allow the RTOS to switch tasks regularly.
  3. Final Answer:

    To generate regular interrupts for task switching -> Option A
  4. Quick Check:

    SysTick timer = periodic interrupts for RTOS [OK]
Hint: SysTick timer triggers interrupts for switching tasks [OK]
Common Mistakes:
  • Confusing SysTick with CPU clock speed control
  • Thinking SysTick stores data
  • Assuming SysTick manages memory
2. Which of the following is the correct way to enable the SysTick timer interrupt in ARM Cortex-M?
easy
A. Write zero to the RELOAD register
B. Set the TICKINT bit in the SysTick CTRL register
C. Clear the ENABLE bit in the SysTick CTRL register
D. Disable the NVIC interrupt controller

Solution

  1. Step 1: Identify the control register bits

    The SysTick CTRL register controls timer and interrupt enabling.
  2. Step 2: Enable interrupt by setting TICKINT bit

    Setting the TICKINT bit enables SysTick interrupts.
  3. Final Answer:

    Set the TICKINT bit in the SysTick CTRL register -> Option B
  4. Quick Check:

    Enable interrupt = set TICKINT bit [OK]
Hint: Enable SysTick interrupt by setting TICKINT bit [OK]
Common Mistakes:
  • Clearing ENABLE disables timer, not interrupt
  • Writing zero to RELOAD stops timer from counting
  • Disabling NVIC stops all interrupts, not just SysTick
3. Given a CPU clock of 48 MHz and a desired RTOS tick interval of 1 ms, what reload value should be set in the SysTick timer?
medium
A. 47999
B. 480
C. 48000
D. 47

Solution

  1. Step 1: Calculate ticks per 1 ms interval

    CPU clock = 48,000,000 Hz means 48,000 ticks per 1 ms (since 1 ms = 0.001 s).
  2. Step 2: Determine reload value

    Reload value = ticks per interval - 1 = 48000 - 1 = 47999.
  3. Final Answer:

    47999 -> Option A
  4. Quick Check:

    Reload = (CPU clock * tick interval) - 1 = 47999 [OK]
Hint: Reload = (CPU clock x interval) - 1 [OK]
Common Mistakes:
  • Using CPU clock directly without subtracting 1
  • Confusing microseconds with milliseconds
  • Using too small reload value causing faster ticks
4. A developer sets the SysTick reload value to 0 and enables the timer and interrupt. What issue will occur?
medium
A. System will reset immediately
B. SysTick will never generate interrupts
C. CPU clock speed will increase
D. SysTick will generate interrupts continuously without delay

Solution

  1. Step 1: Understand reload value effect

    A reload value of 0 means the timer counts from 0 to 0, triggering interrupt immediately.
  2. Step 2: Resulting behavior

    This causes continuous interrupts with no delay, overwhelming the system.
  3. Final Answer:

    SysTick will generate interrupts continuously without delay -> Option D
  4. Quick Check:

    Reload=0 causes continuous interrupts [OK]
Hint: Reload 0 means no delay, interrupts fire nonstop [OK]
Common Mistakes:
  • Assuming no interrupts occur with reload 0
  • Thinking CPU clock changes due to SysTick
  • Expecting system reset from this setting
5. In an RTOS using SysTick for task switching, if the CPU clock changes dynamically (e.g., due to power saving), what must be done to maintain correct tick timing?
hard
A. Disable SysTick and rely on software delays
B. Keep the reload value fixed regardless of clock changes
C. Update the SysTick reload value to match the new CPU clock frequency
D. Increase the interrupt priority of SysTick

Solution

  1. Step 1: Recognize effect of CPU clock changes

    SysTick timer counts CPU clock cycles, so changing clock speed affects tick timing.
  2. Step 2: Adjust reload value accordingly

    To keep tick interval constant, reload value must be recalculated based on new CPU clock.
  3. Final Answer:

    Update the SysTick reload value to match the new CPU clock frequency -> Option C
  4. Quick Check:

    Adjust reload for clock changes to keep tick timing [OK]
Hint: Reload value must match CPU clock for correct ticks [OK]
Common Mistakes:
  • Ignoring clock changes and keeping reload fixed
  • Disabling SysTick breaks RTOS timing
  • Changing interrupt priority doesn't fix timing
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard