libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.

libopencm3 Cortex System Tick Timer More...

Collaboration diagram for SysTick:

Functions

void systick_set_reload (uint32_t value)
 SysTick Set the Automatic Reload Value. More...
 
uint32_t systick_get_reload (void)
 SysTick Read the Automatic Reload Value. More...
 
bool systick_set_frequency (uint32_t freq, uint32_t ahb)
 SysTick Set clock and frequency of overflow. More...
 
uint32_t systick_get_value (void)
 Get the current SysTick counter value. More...
 
void systick_set_clocksource (uint8_t clocksource)
 Set the SysTick Clock Source. More...
 
void systick_interrupt_enable (void)
 Enable SysTick Interrupt. More...
 
void systick_interrupt_disable (void)
 Disable SysTick Interrupt. More...
 
void systick_counter_enable (void)
 Enable SysTick Counter. More...
 
void systick_counter_disable (void)
 Disable SysTick Counter. More...
 
uint8_t systick_get_countflag (void)
 SysTick Read the Counter Flag. More...
 
void systick_clear (void)
 SysTick Clear counter Value. More...
 
uint32_t systick_get_calib (void)
 SysTick Get Calibration Value. More...
 

Detailed Description

libopencm3 Cortex System Tick Timer

Version
1.0.0
Author
© 2010 Thomas Otto tommi.nosp@m.@via.nosp@m.dmin..nosp@m.org
Date
19 August 2012

This library supports the System Tick timer in ARM Cortex Microcontrollers.

The System Tick timer is part of the ARM Cortex core. It is a 24 bit down counter that can be configured with an automatical reload value.

LGPL License Terms libopencm3 License

Function Documentation

◆ systick_clear()

void systick_clear ( void  )

SysTick Clear counter Value.

The counter value is cleared. Useful for well defined startup.

Definition at line 187 of file systick.c.

References STK_CVR.

◆ systick_counter_disable()

void systick_counter_disable ( void  )

Disable SysTick Counter.

Definition at line 162 of file systick.c.

References STK_CSR.

◆ systick_counter_enable()

void systick_counter_enable ( void  )

Enable SysTick Counter.

Definition at line 152 of file systick.c.

References STK_CSR, and STK_CSR_ENABLE.

◆ systick_get_calib()

uint32_t systick_get_calib ( void  )

SysTick Get Calibration Value.

Returns
Current calibration value

Definition at line 197 of file systick.c.

References STK_CALIB, and STK_CALIB_TENMS.

◆ systick_get_countflag()

uint8_t systick_get_countflag ( void  )

SysTick Read the Counter Flag.

The count flag is set when the timer count becomes zero, and is cleared when the flag is read.

Returns
Boolean if flag set.

Definition at line 176 of file systick.c.

References STK_CSR, and STK_CSR_COUNTFLAG.

◆ systick_get_reload()

uint32_t systick_get_reload ( void  )

SysTick Read the Automatic Reload Value.

Returns
24 bit reload value as uint32_t.

Definition at line 66 of file systick.c.

References STK_RVR, and STK_RVR_RELOAD.

◆ systick_get_value()

uint32_t systick_get_value ( void  )

Get the current SysTick counter value.

Returns
24 bit current value as uint32_t.

Definition at line 108 of file systick.c.

References STK_CVR, and STK_CVR_CURRENT.

◆ systick_interrupt_disable()

void systick_interrupt_disable ( void  )

Disable SysTick Interrupt.

Definition at line 142 of file systick.c.

References STK_CSR.

◆ systick_interrupt_enable()

void systick_interrupt_enable ( void  )

Enable SysTick Interrupt.

Definition at line 132 of file systick.c.

References STK_CSR, and STK_CSR_TICKINT.

◆ systick_set_clocksource()

void systick_set_clocksource ( uint8_t  clocksource)

Set the SysTick Clock Source.

The clock source can be either the AHB clock or the same clock divided by 8.

Parameters
[in]clocksourceuint8_t. Clock source from Clock source selection.

Definition at line 121 of file systick.c.

References STK_CSR, and STK_CSR_CLKSOURCE.

Referenced by systick_set_frequency().

Here is the caller graph for this function:

◆ systick_set_frequency()

bool systick_set_frequency ( uint32_t  freq,
uint32_t  ahb 
)

SysTick Set clock and frequency of overflow.

This function sets the systick to AHB clock source, and the prescaler to generate interrupts with the desired frequency. The function fails, if the frequency is too low.

Parameters
[in]frequint32_t The desired frequency in Hz
[in]ahbuint32_t The current AHB frequency in Hz
Returns
true, if success, false if the desired frequency cannot be set.

Definition at line 81 of file systick.c.

References STK_CSR_CLKSOURCE_AHB, STK_CSR_CLKSOURCE_AHB_DIV8, STK_RVR_RELOAD, systick_set_clocksource(), and systick_set_reload().

Here is the call graph for this function:

◆ systick_set_reload()

void systick_set_reload ( uint32_t  value)

SysTick Set the Automatic Reload Value.

The counter is set to the reload value when the counter starts and after it reaches zero.

Note
The systick counter value might be undefined upon startup. To get predictable behavior, it is a good idea to set or clear the counter after set reload.
See also
systick_clear
Parameters
[in]valueuint32_t. 24 bit reload value.

Definition at line 55 of file systick.c.

References STK_RVR, and STK_RVR_RELOAD.

Referenced by systick_set_frequency().

Here is the caller graph for this function: