This object encapsulates some useful features common to all Cortex-M MCUs, currently mostly SysTick timer-related. The SysTick timer is a free-running 24-bit counter defined in the ARM Cortex-M architecture. While it is nominally optional, all currently commonly available MCUs include this feature. The SysTick timer is useful for implementing delay functions (see below), generating periodic interrupts for RTOS, etc.

You call the function SysTick_Timer to initialize the SysTick timer. The parameter granularity specifies how frequent the timer should run, from once every 10 microseconds to once every hundredth of a second. As there is overhead in interrupt processing, you should not set the frequency too high. For example, with a system clock of 84 MHz, interrupting every 10 microsecond means that the CPU can only execute about 800+ instructions between each interrupt. The value SYSTICK_MILLISECOND is a good “Goldilocks” value to use – not too high and not too low, unless high accuracy in SysTick timing is required. In case high-accuracy timing is needed, you can set the SysTick timer to run faster, or you can use the regular timers instead of the SysTick timer.

The SysTick_TimerAddHook function lets you add a hook function to the SysTick timer. Whenever the SysTick interrupt handler is called, it will call the hook function. This allows the user program to perform periodic tasks without using up another timer.


extern jsapi_cortex_core








Set the granularity of the SysTick timer and start it

void SysTick_Timer (

    enum SYSTICK_GRANULARITY granularity,

    int priority


Hook into the SysTick interrupt

void SysTick_TimerAddHook(void (*func)(void));

Enable or Disable the SysTick timer

void SysTick_SetState(bool enable);

Return the current value of the SysTick timer

unsigned SysTick_CurrentValue(void);


JumpStart API defines some delay functions that rely on the SysTick timer. As these function names are ubiquitous, they are accessed as regular functions, and not through a C++ object. The SysTick timer must be set up to accommodate the delay period. For example, to support 10-microsecond delays, the SysTick Timer must be set up to have a granularity of 10 microseconds or less. Otherwise, the delay function will return immediately.

These delay functions are compatible with using SysTick for RTOS or other periodic time keeping functions, as they do not reload or reset the SysTick registers. They are also low-power compatible, and use the WFI assembly instructions while waiting for the delay to expire.

These delay functions are not reentrant, so they cannot be called from within an interrupt handler that has interrupted a running delay function. Also, if they are called by an interrupt handler, then that interrupt’s priority cannot be higher than the SysTick interrupt priority. Otherwise, the SysTick interrupt will not run, and the delay function will never terminate.

Delay for a specified ‘x’ 10 microseconds

void Delay10MicroSecs(unsigned delay);

Delay for a specified ‘x’ 100 microseconds

void Delay100MicroSecs(unsigned delay);

Delay for a specified ‘x’ milliseconds

void DelayMilliSecs(unsigned delay);

Delay for a specified ‘x’ hundredths of a second

void DelayHundredth(unsigned delay);

Delay for a specified ‘x’ tenths of a second

void DelayTenth(unsigned delay);

Delay for a specified ‘x’ seconds

void DelaySeconds(unsigned delay);


How to Use

To use the JumpStart Cortex Core API with the jsapi_cortex_core object:

1.       Call SysTick_Timer to initialize the SysTick timer.

Example 1

// 10 millisecond systick


unsigned start = jsapi_core.SysTick_CurrentValue();


unsigned delta = jsapi_core.SysTick_CurrentValue() - start;

printf(“SysTick delta should be ~200 = %d\n”, delta);

Example 2: Using the Hook Function


void myHandler(void)


    printf(“current systick is %d\n”,



    // somewhere in main()