4. SysTick Introduction
The System Tick Timer (SysTick) generates interrupt requests on a regular basis.
This allows an OS to carry out context switching to support multiple tasking.
5. SysTick Introduction
ARM
Cortex-M3
Timer
On-Chip
peripherals
JTAG
SWD
CPU
SysTick
NVIC
Chips from different
manufacturers
NVIC
ARM
Cortex-M3 Kernel
Nested Vector
Interrupt
Controller
SysTick is a 24-bit system clock
counter, down counting mode, it
belongs to ARM Cortex-M3 kernel
NVIC in a functional unit, often used
for operating system clock timing.
Without operating system, the Systick can
be used as a general timer/counter
6. JTAG & SWD
Serial Wire Debug (SWD) is a 2-pin (SWDIO/SWCLK) electrical alternative
JTAG interface that has the same JTAG protocol on top.
SWD uses an ARM CPU standard bi-directional wire protocol.
Joint Test Action Group (JTAG) is an
electronics industry association formed in
1985 for developing a method of verifying
designs and testing printed circuit
boards after manufacture.
7. NVIC (Nested Vector
Interrupt Controller)
Asynchronous interrupts don’t wait for previous
ones to be handled - if you’re handling the last
one when a new one comes along, you either
ignore it or you have a CPU that can nest them
and handle it when you finish the current one
(or preserve the current state and handle the
new one - it depends on priority).
10. SysTick Introduction
Systick timers can be used for other purposes in
addition to operating systems: as a alarm, for
measuring time.
Note that when the processor is called to stop
during debugging (Halt), the Systick timer will
also be suspended.
14. Register description
SysTick Control and Status registers (SysTick_CSR)
COUNTFLAG CLKSOURCE TICKINT ENABLE
bit0
bit1
bit2
bit16
Counter flag bit
0: Read zeroing
1: The counting value is
reduced from 1 to 0
Clock source Selection bit
0: External reference clock-HCLK/8
1: Kernel clock-HCLK
0: No interruption
1: Allow interrupt
Interrupt Enable
bit
Counter enables bit
0: Prohibition
1: Enable
Count values from 1 to 0
triggers an Interrupt.
The bit will automatically
clear 0 after reading;
can be used for query
mode timing
15. SysTick Clock source
SysTick's clock
source can be
HCLK/8 or
HCLK
specifically
which can be
selected by
configuring
control and
status registers
(CTRL).
16. 0
Current Value Registers (SysTick_VAL)
Register description
The current value register displays the current value of the SysTick
counter. Every 1 system clock cycles, the value minus 1, when the
count is reduced to 0, can produce interrupts and load the values of
the reload value registers.
0x000003
Count Flag bit
COUNTFLAG
Interrupt
Current Value Registers
Reload Value Registers
0x000003
0x000002
0x000001
0x000000
0x000003
0x000003
1
0x000000
Any value
Write any value to zero and
cause the sign to be zeroed.
18. SysTick How to Run
Select Clock Source
Set Reload values
Enable SysTick interruption
Enable SysTick counter
CTRL—>CLKSOURCE
When the count value is reduced from 1 to 0,
the interrupt is generated
Start Counter & Start Countdown
RELOAD=(SysClock * Timing time) -1
Empty Current Value Registers Automatically load reload values when the count is 0
19. SysTick How to Run
CURRENT
FLAG
0x000003
RELOAD
0x000000
0
ENABLE TICKINT
CLKSOURCE
0
1
Clock Interrupt
Select Kernel Clock
1 Set Reload values
2
Enable interruption
3
Enable counter
4
0x000003
0x000002
0x000000
0x000001
1
Interrupt
1 1