2359 views|0 replies

16

Posts

0

Resources
The OP
 

[Serial] [Starlight Lightning STM32F407 Development Board] Chapter 6 SysTick Test [Copy link]

Chapter 6 SysTickExperiment 6.1 Purpose of the experiment
Through this experiment, we will learn how to use the SysTick timer (the heartbeat of the operating system) to achieve accurate timing.
6.2 Experimental Introduction The SysTick timer is bundled in the NVIC and is used to generate SysTick exceptions. In the past, the operating system and all systems that use a time base must have a hardware timer to generate the required "tick" interrupt as the time base of the entire system. Tick interrupts are particularly important for operating systems. For example, the operating system can grant different numbers of time slices to multiple tasks to ensure that no task can monopolize the system; or grant a certain time range of each timer cycle to a specific task, etc., and the various timing functions provided by the operating system are all related to this tick timer. Therefore, a timer is needed to generate periodic interrupts, and it is best to prevent user programs from arbitrarily accessing its registers to maintain the rhythm of the operating system's "heartbeat". All Cortex M4s have this timer, which is a core component of Cortex. All CM4 chips have the same SysTick and are processed in the same way, which makes it much easier to port operating systems and software based on this timer between all CM4 chips. SysTick is a 24-bit timer. The counter works in a decrementing manner. When it decrements to 0, the hardware automatically reloads the count value. If the interrupt is enabled, an interrupt is generated. Its usage and configuration are very simple. Let's take a look at it:
There are 4 SYysTick registers as follows. Generally, we only use the first 3
STK_CTRL System Timer Control and Status Register RW 0 0 E000 E010 0xE000E010
Name
Description
Access
Reset Value
Address
STK_LOAD
System timer reload value register
[align= center]RW
Unknown
0xE000E014
STK_VAL
System timer current value register
[align= center]RW
Unknown
0xE000E018
STK_CALIB
System timer calibration value register
RO
0xC0000000
0xE000E01C
SysTick control register, which must be configured during initialization.
SysTick reload register, every time the count reaches 0, this register value is automatically loaded into SysTick's down counter.
SysTick's down counter
6.3 Circuit Design
The SysTick timer belongs to the internal resources of STM32 and does not require external circuits. Here, the onboard D5 and D6 indicator lights are used to flash cyclically to indicate the timing function of SysTick. The circuit diagram is omitted.
6.4 Software Design Open 3 in the CD directory, program source code->1, basic experiment->experiments3 SysTick experimental project, open the Systick.c file under the BSP directory on the left, which is the driver file of SysTick. The project directory is shown in the figure below:385719Figure 6.4.1Open the Systick.c file, the code is as follows:
Figure6.4.2
Open the main.c file, initialize the system clock, LED pin configuration and SysTick interrupt setting. Whenever the 1S interrupt arrives, flip the output states of the two LEDs D5 and D6 to implement Roman]LED flashes,code is as follows:
Figure 6.4.3
6.5 Download verification
Use a MINI USB cable to connect the computer and the development board through the USB port of CN3, turn on the power switch to power on the development board, the D3 power indicator lights up, connect the JLINK/ST-LINK download debugger, open the "Experiment 3 SysTick Experiment" project code, compile and download, D4 , D5 indicator light flashes at 1S intervals, the buzzer sounds, use a jumper to short-circuit pins 1 and 3 of the P8 header, connect D4 to the PB0 pin of the STM32, and repeat the cycle.
This content was originally created by EEWORLD forum user hejecu. If you need to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source


图片4.png (12.54 KB, downloads: 0)

图片4.png

实验3 SysTick实验.zip

642.37 KB, downloads: 5

This post is from stm32/stm8
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list