libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
|
libopencm3 Defined Constants and Types for the Cortex SysTick More...
Modules | |
STK_CSR Values | |
STK_RVR Values | |
STK_CALIB Values | |
Macros | |
#define | STK_CSR MMIO32(SYS_TICK_BASE + 0x00) |
SysTick Control and Status Register (CSR). More... | |
#define | STK_RVR MMIO32(SYS_TICK_BASE + 0x04) |
SysTick Reload Value Register (RVR). More... | |
#define | STK_CVR MMIO32(SYS_TICK_BASE + 0x08) |
SysTick Current Value Register (CVR). More... | |
#define | STK_CALIB MMIO32(SYS_TICK_BASE + 0x0C) |
SysTick Calibration Value Register(Read Only) (CALIB) Reads the calibration value and parameters for SysTick. More... | |
Functions | |
void | systick_set_reload (uint32_t value) |
SysTick Set 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_reload (void) |
SysTick Read the Automatic Reload Value. 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... | |
libopencm3 Defined Constants and Types for the Cortex SysTick
System Control Space (SCS) => System timer register support in the SCS. To configure SysTick, load the interval required between SysTick events to the SysTick Reload Value register. The timer interrupt, or COUNTFLAG bit in the SysTick Control and Status register, is activated on the transition from 1 to 0, therefore it activates every n+1 clock ticks. If you require a period of 100, write 99 to the SysTick Reload Value register. The SysTick Reload Value register supports values between 0x1 and 0x00FFFFFF.
If you want to use SysTick to generate an event at a timed interval, for example 1ms, you can use the SysTick Calibration Value Register to scale your value for the Reload register. The SysTick Calibration Value Register is a read-only register that contains the number of pulses for a period of 10ms, in the TENMS field, bits[23:0].
This register also has a SKEW bit. Bit[30] == 1 indicates that the calibration for 10ms in the TENMS section is not exactly 10ms due to clock frequency. Bit[31] == 1 indicates that the reference clock is not provided.
LGPL License Terms libopencm3 License
#define STK_CALIB MMIO32(SYS_TICK_BASE + 0x0C) |
#define STK_CSR MMIO32(SYS_TICK_BASE + 0x00) |
#define STK_CVR MMIO32(SYS_TICK_BASE + 0x08) |
#define STK_RVR MMIO32(SYS_TICK_BASE + 0x04) |
SysTick Reload Value Register (RVR).
Reads or clears the value that will be loaded to the counter. Usage constraints:
void systick_clear | ( | void | ) |
void systick_counter_disable | ( | void | ) |
void systick_counter_enable | ( | void | ) |
Enable SysTick Counter.
Definition at line 152 of file systick.c.
References STK_CSR, and STK_CSR_ENABLE.
uint32_t systick_get_calib | ( | void | ) |
SysTick Get Calibration Value.
Definition at line 197 of file systick.c.
References STK_CALIB, and STK_CALIB_TENMS.
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.
Definition at line 176 of file systick.c.
References STK_CSR, and STK_CSR_COUNTFLAG.
uint32_t systick_get_reload | ( | void | ) |
SysTick Read the Automatic Reload Value.
Definition at line 66 of file systick.c.
References STK_RVR, and STK_RVR_RELOAD.
uint32_t systick_get_value | ( | void | ) |
Get the current SysTick counter value.
Definition at line 108 of file systick.c.
References STK_CVR, and STK_CVR_CURRENT.
void systick_interrupt_disable | ( | void | ) |
void systick_interrupt_enable | ( | void | ) |
Enable SysTick Interrupt.
Definition at line 132 of file systick.c.
References STK_CSR, and STK_CSR_TICKINT.
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.
[in] | clocksource | uint8_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().
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.
[in] | freq | uint32_t The desired frequency in Hz |
[in] | ahb | uint32_t The current AHB frequency in Hz |
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().
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.
[in] | value | uint32_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().