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

§ SysTickDisable()

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
111 {
112  // Disable SysTick.
113  HWREG(NVIC_ST_CTRL) &= ~(NVIC_ST_CTRL_ENABLE);
114 }

§ SysTickEnable()

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
94 {
95  // Enable SysTick.
96  HWREG(NVIC_ST_CTRL) |= (NVIC_ST_CTRL_CLK_SRC | NVIC_ST_CTRL_ENABLE);
97 }

§ SysTickIntDisable()

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
200 {
201  // Disable the SysTick interrupt.
202  HWREG(NVIC_ST_CTRL) &= ~(NVIC_ST_CTRL_INTEN);
203 }

§ SysTickIntEnable()

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 when the interrupt handler is called.
Returns
None
183 {
184  // Enable the SysTick interrupt.
185  HWREG(NVIC_ST_CTRL) |= NVIC_ST_CTRL_INTEN;
186 }

§ SysTickIntRegister()

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.
136 {
137  // Register the interrupt handler, returning an error if an error occurs.
138  IntRegister(INT_SYSTICK, pfnHandler);
139 
140  // Enable the SysTick interrupt.
141  HWREG(NVIC_ST_CTRL) |= NVIC_ST_CTRL_INTEN;
142 }
void IntRegister(uint32_t ui32Interrupt, void(*pfnHandler)(void))
Registers a function as an interrupt handler in the dynamic vector table.
Definition: interrupt.c:151
Here is the call graph for this function:

§ SysTickIntUnregister()

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.
159 {
160  // Disable the SysTick interrupt.
161  HWREG(NVIC_ST_CTRL) &= ~(NVIC_ST_CTRL_INTEN);
162 
163  // Unregister the interrupt handler.
164  IntUnregister(INT_SYSTICK);
165 }
void IntUnregister(uint32_t ui32Interrupt)
Unregisters an interrupt handler in the dynamic vector table.
Definition: interrupt.c:187
Here is the call graph for this function:

§ SysTickPeriodGet()

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.
247 {
248  // Return the period of the SysTick counter.
249  return(HWREG(NVIC_ST_RELOAD) + 1);
250 }

§ SysTickPeriodSet()

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
227 {
228  // Check the arguments.
229  ASSERT((ui32Period > 0) && (ui32Period <= 16777216));
230 
231  // Set the period of the SysTick counter.
232  HWREG(NVIC_ST_RELOAD) = ui32Period - 1;
233 }
#define ASSERT(expr)
Definition: debug.h:71

§ SysTickValueGet()

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
264 {
265  // Return the current value of the SysTick counter.
266  return(HWREG(NVIC_ST_CURRENT));
267 }