SysTick Module

The SysTick API provides a set of functions for configuring the SysTick module in the Cortex M core. Functions are provided to configure the systick module including the period and interrupts

group systick_api

This module is used for configurating Systick.

Enums

enum SYSTICK_ClockSource

Values that can be passed to SYSTICK_setClockSource() as the clkSrc parameter.

Values:

enumerator SYSTICK_CLOCK_SOURCE_EXTERNAL = 0x0U

External clock is used.

enumerator SYSTICK_CLOCK_SOURCE_INTERNAL = 0x4U

Internal clock is used.

Functions

void SYSTICK_setClockSource(SYSTICK_ClockSource clkSrc)

Sets the clokc source for SysTick counter.

This function sets the clokc source for SysTick counter. The Systick clock can be set as either internal clock or external. The param clkSrc can take following values:SYSTICK_CLOCK_SOURCE_EXTERNAL and SYSTICK_CLOCK_SOURCE_INTERNAL.

Parameters
  • clkSrc: specifies the clock source type.

Return

None.

void SYSTICK_enableCounter(void)

Enables the SysTick counter.

This function starts the SysTick counter. If an interrupt handler has been registered, it is called when the SysTick counter rolls over.

Note

Calling this function causes the SysTick counter to (re)commence counting from its current value. The counter is not automatically reloaded with the period as specified in a previous call to SysTick_setPeriod(). If an immediate reload is required, the NVIC_O_SYST_CVR register must be written to force the reload. Any write to this register clears the SysTick counter to 0 and causes a reload with the supplied period on the next clock.

Return

None.

void SYSTICK_disableCounter(void)

Disables the SysTick counter.

This function stops the SysTick counter. If an interrupt handler has been registered, it is not called until SysTick is restarted.

Return

None.

void SYSTICK_setPeriod(uint32_t period)

Sets the period of the SysTick counter.

This function sets the rate at which the SysTick counter wraps, which equates to the number of processor clocks between interrupts.

Parameters
  • period: is the number of clock ticks in each period of the SysTick counter and must be between 1 and 16,777,216, inclusive.

Note

Calling this function does not cause the SysTick counter to reload immediately. If an immediate reload is required, the NVIC_O_SYST_CVR register must be written. Any write to this register clears the SysTick counter to 0 and causes a reload with the period supplied here on the next clock after SysTick is enabled.

Return

None.

uint32_t SYSTICK_getPeriod(void)

Gets the period of the SysTick counter.

This function returns the rate at which the SysTick counter wraps, which equates to the number of processor clocks between interrupts.

Return

Returns the period of the SysTick counter.

uint32_t SYSTICK_getCurrentValue(void)

Gets the current value of the SysTick counter.

This function returns the current value of the SysTick counter, which is a value between the period - 1 and zero, inclusive.

Return

Returns the current value of the SysTick counter.

void SYSTICK_enableInterrupt(void)

Enables the SysTick interrupt.

This function enables the SysTick interrupt, allowing it to be reflected to the processor.

Note

The SysTick interrupt handler is not required to clear the SysTick interrupt source because it is cleared automatically by the NVIC when the interrupt handler is called.

Return

None.

void SYSTICK_disableInterrupt(void)

Disables the SysTick interrupt.

This function disables the SysTick interrupt, preventing it from being reflected to the processor.

Return

None.

void SYSTICK_registerInterruptHandler(void (*fnHandler)(void))

Registers an interrupt handler for the SysTick interrupt.

This function registers the handler to be called when a SysTick interrupt occurs.

Parameters
  • fnHandler: is a pointer to the function to be called when the SysTick interrupt occurs.

See

Interrupt_registerHandler() for important information about registering interrupt handlers.

Return

None.

void SYSTICK_unregisterInterruptHandler(void)

Unregisters the interrupt handler for the SysTick interrupt.

This function unregisters the handler to be called when a SysTick interrupt occurs.

See

Interrupt_registerHandler() for important information about registering interrupt handlers.

Return

None.

The code for this module is contained in driverlib_cm/systick.c, with driverlib_cm/systick.h containing the API declarations for use by applications.