Introduction
The system CPU includes a system timer, SysTick, integrated in the NVIC which provides a simple, 24-bit, clear-on-write, decrementing, wrap-on-zero counter with a flexible control mechanism. When enabled, the timer counts down on each clock from the reload value to 0, reloads (wraps) on the next clock edge, then decrements on subsequent clocks.
The SysTick counter runs on the system clock. If this clock signal is stopped for low-power mode, the SysTick counter stops.
When the processor is halted for debugging, the counter does not decrement.
API
The API functions can be grouped like this:
Configuration and status:
Enable and disable:
Interrupt configuration:
static void SysTickDisable |
( |
void |
| ) |
|
|
inlinestatic |
Disables the SysTick counter.
This will stop the SysTick counter. If an interrupt handler has been registered, it will no longer be called until SysTick is restarted.
- Returns
- None
Definition at line 114 of file systick.h.
static void SysTickEnable |
( |
void |
| ) |
|
|
inlinestatic |
Enables the SysTick counter.
This will start the SysTick counter. If an interrupt handler has been registered, it will be called when the SysTick counter rolls over.
- Note
- Calling this function will cause 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 SysTickPeriodSet(). If an immediate reload is required, the NVIC_ST_CURRENT register must be written to force this. Any write to this register clears the SysTick counter to 0 and will cause a reload with the supplied period on the next clock.
- Returns
- None
Definition at line 95 of file systick.h.
static void SysTickIntDisable |
( |
void |
| ) |
|
|
inlinestatic |
Disables the SysTick interrupt.
This function will disable the SysTick interrupt, preventing it from being reflected to the processor.
- Returns
- None
Definition at line 212 of file systick.h.
static void SysTickIntEnable |
( |
void |
| ) |
|
|
inlinestatic |
Enables the SysTick interrupt.
This function will enable the SysTick interrupt, allowing it to be reflected to the processor.
- Note
- The SysTick interrupt handler does not need to clear the SysTick interrupt source as this is done automatically by NVIC when the interrupt handler is called.
- Returns
- None
Definition at line 193 of file systick.h.
static void SysTickIntRegister |
( |
void(*)(void) |
pfnHandler | ) |
|
|
inlinestatic |
Registers an interrupt handler for the SysTick interrupt.
This sets the handler to be called when a SysTick interrupt occurs.
- Parameters
-
pfnHandler | is a pointer to the function to be called when the SysTick interrupt occurs. |
- Returns
- None
- See also
- IntRegister() for important information about registering interrupt handlers.
Definition at line 138 of file systick.h.
static void SysTickIntUnregister |
( |
void |
| ) |
|
|
inlinestatic |
Unregisters the interrupt handler for the SysTick interrupt.
This function will clear the handler to be called when a SysTick interrupt occurs.
- Returns
- None
- See also
- IntRegister() for important information about registering interrupt handlers.
Definition at line 165 of file systick.h.
static uint32_t SysTickPeriodGet |
( |
void |
| ) |
|
|
inlinestatic |
Gets the period of the SysTick counter.
This function returns the rate at which the SysTick counter wraps; this equals to the number of processor clocks between interrupts.
- Returns
- Returns the period of the SysTick counter.
Definition at line 264 of file systick.h.
static void SysTickPeriodSet |
( |
uint32_t |
ui32Period | ) |
|
|
inlinestatic |
Sets the period of the SysTick counter.
This function sets the rate at which the SysTick counter wraps; this equals to the number of processor clocks between interrupts.
- Note
- Calling this function does not cause the SysTick counter to reload immediately. If an immediate reload is required, the NVIC_ST_CURRENT register must be written. Any write to this register clears the SysTick counter to 0 and will cause a reload with the
ui32Period
supplied here on the next clock after the SysTick is enabled.
- Parameters
-
ui32Period | is the number of clock ticks in each period of the SysTick counter; must be between 1 and 16,777,216 (0x1000000), both included. |
- Returns
- None
Definition at line 240 of file systick.h.
static uint32_t SysTickValueGet |
( |
void |
| ) |
|
|
inlinestatic |
Gets the current value of the SysTick counter.
This function returns the current value of the SysTick counter; this will be a value between the (period - 1) and zero, both included.
- Returns
- Returns the current value of the SysTick counter
Definition at line 283 of file systick.h.