CAT2 Peripheral Driver Library
SysTick (ARM System Timer)

Provides vendor-specific SysTick API. More...

Modules

 Macros
 
 Functions
 
 Data Structures
 

Detailed Description

Provides vendor-specific SysTick API.

The functions and other declarations used in this driver are in cy_systick.h. You can include cy_pdl.h to get access to all functions and declarations in the PDL.

The SysTick timer is part of the CPU. The timer is a down counter with a 24-bit reload/tick value that is clocked by the System clock or LF clock. The timer has the capability to generate an interrupt when the set number of ticks expires and the counter is reloaded. This interrupt is available as part of the Nested Vectored Interrupt Controller (NVIC) for service by the CPU and can be used for general-purpose timing control in user code.

The timer is independent of the CPU (except for the clock), which is useful in applications requiring precise timing that do not have a dedicated timer/counter available for the job.

Configuration Considerations

The Cy_SysTick_Init() performs all required driver's initialization and enables the timer. The function accepts two parameters: clock source cy_en_systick_clock_source_t and the timer interval. You must ensure the selected clock source for SysTick is enabled. The callbacks can be registered/unregistered any time after Cy_SysTick_Init() by calling Cy_SysTick_SetCallback().

Changing the SysTick clock source and/or its frequency will change the interrupt interval and therefore Cy_SysTick_SetReload() should be called to compensate for this change.

Example of SysTick initialization. At first define SysTick callback, which will be invoked at each SysTick interrupt.

/*******************************************************************************
* Function Name: SysTick_Callback
****************************************************************************/
void SysTick_Callback(void)
{
/* Some action */
}

At second step initialize SysTick and register created callback function.

/* Initialize SysTick with interval = 1 second, using IL0 = 40 kHz as a source */
/* Register one of the SysTick callbacks */
Cy_SysTick_SetCallback(0UL, &SysTick_Callback);

More Information

Refer to the SysTick section of the ARM reference guide for complete details on the registers and their use. See also the "CPU Subsystem (CPUSS)" chapter of the device technical reference manual (TRM).

Changelog

VersionChangesReason for Change
1.20.2 Update the paths to the code snippets. PDL structure update.
1.20.1
  • Added information that setting reload value to zero has no effect because the SysTick exception request and count flag are activated when counting from 1 to 0.
Documentation enhancement.
1.20 Implementation enhancement.
1.10 Implementation and documentation enhancements.
1.0 Initial version