SYSTICK Interrupt

SYSTICK interrupt is an optional but almost always implemented feature of a Cortex-M based MCU. It provides a system timer that is (almost always) available, and is useful for providing a timer for implementing an RTOS and other capabilities. The following SYSTICK-related functions are available in CMSIS:


SysTick_Config(uint32_t ticks) sets the number of “ticks” between each SYSTICK interrupt. For example, to configure the SYSTICK timer to fire every 10 milliseconds, write SysTick_Config(SystemCoreClock / 100) where SystemCoreClock is defined in CMSIS and contains the system clock frequency (e.g. 72000000 for 72 MHz clock).


NVIC_SetPriority(SYSTICK_IRQn, priority) sets the priority of the SYSTICK interrupt. NOTE: SYSTICK_IRQn is usually defined in one of the MCU specific header files. If not, then use -1.


NVIC_DisableIRQ(SYSTICK_IRQn) and NVIC_EnableIRQ(SYSTICK_IRQn) disables and enables the SYSTICK interrupt respectively.