SoC
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
  • Arm Cortex M3
  • Contact
Reading: What is SysTick 24-bit timer in Arm Cortex-M series?
SUBSCRIBE
SoCSoC
Font ResizerAa
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Search
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Have an existing account? Sign In
Follow US
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
© S-O-C.ORG, All Rights Reserved.
Arm

What is SysTick 24-bit timer in Arm Cortex-M series?

Mike Johnston
Last updated: September 17, 2023 12:48 pm
Mike Johnston 6 Min Read
Share
SHARE

The SysTick timer is a 24-bit down counter built into the Cortex-M series of ARM processors. It provides microsecond timing capabilities and is commonly used for operating system ticks in RTOS applications. The SysTick timer runs on the processor clock and can generate periodic interrupts for timing events.

Contents
Overview of SysTick TimerSysTick Timer Key FeaturesUsing the SysTick TimerRTOS Tick GenerationCreate Execution DelaysBenchmarkingPeriodic Data AcquisitionSysTick Timer RegistersSysTick Interrupt HandlerSysTick Timer ConfigurationUsing SysTick Timer with RTOSAdvantages of SysTick TimerConclusion

Overview of SysTick Timer

The SysTick timer module includes a 24-bit down counter that counts down from a reload value to zero. Once the counter reaches zero, it generates an interrupt and reloads the counter value again. This creates a periodic tick interrupt that can be used for task scheduling in a real-time operating system (RTOS).

In addition to the down counter, the SysTick timer module contains a clock source, interrupt generation logic, and control registers. The clock source can either be the processor clock or an external reference clock. The control registers allow software to configure the timer reload value, interrupt enables, and operating modes.

SysTick Timer Key Features

  • 24-bit down counter
  • Programmable reload value
  • Processor clock or external clock source
  • Configurable interrupt enables
  • Accessible control registers

Using the SysTick Timer

The SysTick timer is commonly used for the following purposes in Cortex-M embedded applications:

RTOS Tick Generation

The SysTick interrupt provides a periodic tick that can be used for task scheduling and timekeeping in a real-time operating system. By configuring the reload value, the RTOS can set the desired tick frequency. The tick handler then calls the scheduler to switch tasks.

Create Execution Delays

By polling the SysTick counter in a loop, firmware can create execution delays or timeouts for operations. This provides microsecond timing without blocking other interrupts.

Benchmarking

The SysTick counter can measure elapsed time between events in the application. This allows benchmarking routines, execution profiling, and performance monitoring.

Periodic Data Acquisition

With the periodic tick interrupt, the SysTick timer provides accurate pacing for reading sensors or sampling data at fixed intervals in the milliseconds to microseconds range.

SysTick Timer Registers

The SysTick timer includes several registers that control its operation:

  • SYST_CSR – Control and status register to start/stop counter, generate interrupt, select clock source.
  • SYST_RVR – Reload value register sets tick interval.
  • SYST_CVR – Current value register indicates current counter value.
  • SYST_CALIB – Calibration value register for clock frequency.

These registers allow complete control over the timer behavior in software. They are accessed using the System Timer (SYST) addresses in the Cortex-M memory map.

SysTick Interrupt Handler

The SysTick timer includes an interrupt line to the Nested Vectored Interrupt Controller (NVIC). When the timer expires, it asserts the SysTick interrupt to the NVIC. This triggers execution of the SysTick interrupt handler.

The user application must implement a SysTick_Handler() ISR to respond to the periodic tick interrupts. This ISR would contain the RTOS tick handler or other routines to execute on each tick.

SysTick Timer Configuration

To configure the SysTick timer, the firmware typically performs the following steps:

  1. Enable SysTick module in SYST_CSR
  2. Select clock source (internal or external)
  3. Write the desired reload value to SYST_RVR
  4. Enable SysTick interrupt
  5. Start the SysTick counter
  6. Implement SysTick_Handler() ISR

This configures the timer period and attaches the handler to service the interrupts. Once enabled, the SysTick timer will begin generating tick interrupts at the configured rate.

Using SysTick Timer with RTOS

For real-time operating systems, the SysTick timer is commonly used to generate the RTOS tick interrupts. This tick drives task scheduling and provides time reference to the kernel. To integrate SysTick with an RTOS:

  • Configure RTOS tick rate by setting SYST_RVR
  • Implement SysTick_Handler() to call RTOS tick handler
  • Start SysTick timer
  • In tick ISR, call OS tick function to schedule tasks
  • OS uses ticks for timeout management, delays, etc

This RTOS integration allows task switching, time management, resource sharing under the control of the kernel. The SysTick tick provides consistent pacing for the scheduler.

Advantages of SysTick Timer

Key advantages of using the SysTick timer in Cortex-M systems:

  • Dedicated timing peripheral, avoids loading main CPU
  • Microsecond to millisecond accuracy
  • Fully configurable with software accessible registers
  • Integrated interrupt generation
  • Common feature across Cortex-M chips

By offloading timing tasks from the CPU to the SysTick module, it can improve timing accuracy and lower software overhead in embedded applications.

Conclusion

The SysTick timer provides essential timekeeping capabilities in Cortex-M processors. Its 24-bit down counter and periodic interrupts enable accurate task scheduling, benchmarking, delays, timeouts, and other key functions. Proper configuration allows the SysTick timer to serve as the heartbeat for RTOS task switching. With its wide availability across the Cortex-M family, the SysTick timer eases portability and guarantees microsecond timing in most ARM embedded designs.

Newsletter Form (#3)

More ARM insights right in your inbox

 


Share This Article
Facebook Twitter Email Copy Link Print
Previous Article Here are the completed keywords in the requested format
Next Article What are Single-cycle I/O port in Arm Cortex-M series?
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

2k Followers Like
3k Followers Follow
10.1k Followers Pin
- Sponsored-
Ad image

You Might Also Like

What is Timer Mode in ARM?

ARM processors provide several different timer modes that allow developers…

7 Min Read

Options for Acquiring Cortex-M1 and M0 Soft Cores

There are a few options available for acquiring Cortex-M1 and…

6 Min Read

Arm GCC Compiler

The ARM GCC compiler is a free and open source…

7 Min Read

How and with what tools to check firmware code coverage in RTL simulation phase? ARM Cortex-M0/M0+?

To check firmware code coverage during RTL simulation for ARM…

7 Min Read
SoCSoC
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
Welcome Back!

Sign in to your account