systick.h

System timer (SysTick) support.

Types

struct systick_reg_map

SysTick register map type.

Public Members
__io uint32 CSR

Control and status register.

__io uint32 RVR

Reload value register.

__io uint32 CNT

Current value register (“count”)

__io uint32 CVR

Calibration value register.

Devices

None.

Functions

void systick_init(uint32 reload_val)

Initialize and enable SysTick.

Clocks the system timer with the core clock, turns it on, and enables interrupts.

Parameters:
  • reload_val -

    Appropriate reload counter to tick every 1 ms.

void systick_enable()

Clock the system timer with the core clock and turn it on; interrupt every 1 ms, for systick_timer_millis.

void systick_disable()

Clock the system timer with the core clock, but don’t turn it on or enable interrupt.

uint32 systick_uptime(void)

Returns the system uptime, in milliseconds.

uint32 systick_get_count(void)

Returns the current value of the SysTick counter.

uint32 systick_check_underflow(void)

Check for underflow.

This function returns 1 if the SysTick timer has counted to 0 since the last time it was called. However, any reads of any part of the SysTick Control and Status Register SYSTICK_BASE->CSR will interfere with this functionality. See the ARM Cortex M3 Technical Reference Manual for more details (e.g. Table 8-3 in revision r1p1).

Register Map Base Pointers

SYSTICK_BASE

SysTick register map base pointer.

Register Bit Definitions

Control and status register

SYSTICK_CSR_COUNTFLAG

SYSTICK_CSR_CLKSOURCE

SYSTICK_CSR_CLKSOURCE_EXTERNAL

SYSTICK_CSR_CLKSOURCE_CORE

SYSTICK_CSR_TICKINT

SYSTICK_CSR_TICKINT_PEND

SYSTICK_CSR_TICKINT_NO_PEND

SYSTICK_CSR_ENABLE

SYSTICK_CSR_ENABLE_MULTISHOT

SYSTICK_CSR_ENABLE_DISABLED

Calibration value register

SYSTICK_CVR_NOREF

SYSTICK_CVR_SKEW

SYSTICK_CVR_TENMS