CC26xx Driver Library
[systick.h] System Tick

Functions

static void SysTickEnable (void)
 Enables the SysTick counter. More...
 
static void SysTickDisable (void)
 Disables the SysTick counter. More...
 
static void SysTickIntRegister (void(*pfnHandler)(void))
 Registers an interrupt handler for the SysTick interrupt in the dynamic interrupt table. More...
 
static void SysTickIntUnregister (void)
 Unregisters the interrupt handler for the SysTick interrupt in the dynamic interrupt table. More...
 
static void SysTickIntEnable (void)
 Enables the SysTick interrupt. More...
 
static void SysTickIntDisable (void)
 Disables the SysTick interrupt. More...
 
static void SysTickPeriodSet (uint32_t ui32Period)
 Sets the period of the SysTick counter. More...
 
static uint32_t SysTickPeriodGet (void)
 Gets the period of the SysTick counter. More...
 
static uint32_t SysTickValueGet (void)
 Gets the current value of the SysTick counter. More...
 

Detailed Description

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:

Function Documentation

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
113 {
114  // Disable SysTick.
115  HWREG(NVIC_ST_CTRL) &= ~(NVIC_ST_CTRL_ENABLE);
116 }
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
96 {
97  // Enable SysTick.
98  HWREG(NVIC_ST_CTRL) |= NVIC_ST_CTRL_CLK_SRC | NVIC_ST_CTRL_ENABLE;
99 }
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
202 {
203  // Disable the SysTick interrupt.
204  HWREG(NVIC_ST_CTRL) &= ~(NVIC_ST_CTRL_INTEN);
205 }
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
185 {
186  // Enable the SysTick interrupt.
187  HWREG(NVIC_ST_CTRL) |= NVIC_ST_CTRL_INTEN;
188 }
static void SysTickIntRegister ( void(*)(void)  pfnHandler)
inlinestatic

Registers an interrupt handler for the SysTick interrupt in the dynamic interrupt table.

Note
Only use this function if you want to use the dynamic vector table (in SRAM)!

This function registers a function as the interrupt handler for a specific interrupt and enables the corresponding interrupt in the interrupt controller.

Parameters
pfnHandleris 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.
138 {
139  // Register the interrupt handler, returning an error if an error occurs.
140  IntRegister(INT_SYSTICK, pfnHandler);
141 
142  // Enable the SysTick interrupt.
143  HWREG(NVIC_ST_CTRL) |= NVIC_ST_CTRL_INTEN;
144 }
void IntRegister(uint32_t ui32Interrupt, void(*pfnHandler)(void))
Registers a function as an interrupt handler in the dynamic vector table.
Definition: interrupt.c:153

Here is the call graph for this function:

static void SysTickIntUnregister ( void  )
inlinestatic

Unregisters the interrupt handler for the SysTick interrupt in the dynamic interrupt table.

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.
161 {
162  // Disable the SysTick interrupt.
163  HWREG(NVIC_ST_CTRL) &= ~(NVIC_ST_CTRL_INTEN);
164 
165  // Unregister the interrupt handler.
166  IntUnregister(INT_SYSTICK);
167 }
void IntUnregister(uint32_t ui32Interrupt)
Unregisters an interrupt handler in the dynamic vector table.
Definition: interrupt.c:189

Here is the call graph for this function:

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.
248 {
249  // Return the period of the SysTick counter.
250  return(HWREG(NVIC_ST_RELOAD) + 1);
251 }
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
ui32Periodis 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
228 {
229  // Check the arguments.
230  ASSERT((ui32Period > 0) && (ui32Period <= 16777216));
231 
232  // Set the period of the SysTick counter.
233  HWREG(NVIC_ST_RELOAD) = ui32Period - 1;
234 }
#define ASSERT(expr)
Definition: debug.h:73
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
265 {
266  // Return the current value of the SysTick counter.
267  return(HWREG(NVIC_ST_CURRENT));
268 }