Analysis of STM32 Systick timer

Publisher:yuehuiLatest update time:2018-07-17 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

There is a Systick timer in the ARM Cortex-M3 core, which is a 24-bit countdown timer. When the count reaches 0, it will automatically reload the initial value of the timer from the Load register. As long as the ENABLE in the CTRL register is not cleared to 0, it will never stop. The understanding of the tick timer is mainly divided into the following items:

1. Clock source of tick timer


Looking at the above picture, you may have an illusion that the tick timer is 1/8 of the system clock. In fact, it is not. The clock of the tick timer can be either HCLK/8 or HCLK. This is set through the CTRL register. Knowing this is very important for the clock calculation of the operating system, because the clock time must be calculated accurately.

2. Tick timer register

From here we can see that there are two options for the clock source



3. Tick timer library function

  (1) Where are the registers defined? ————In core_cm3.h.

typedef struct {   

 __IO uint32_t CTRL;      

 __IO uint32_t LOAD;     

__IO uint32_t VAL;      

__I  uint32_t CALIB;   

} SysTick_Type; …   

#define SysTick  ((SysTick_Type *) SysTick_BASE)   

(2) Setting steps

①. Select the clock source

②Set the number of reloads (reload)

③ Enable interrupt

④Start the tick timer


Keywords:STM32 Reference address:Analysis of STM32 Systick timer

Previous article:STM32 uses SysTick for accurate timing
Next article:SysTick timer and delay function

Recommended ReadingLatest update time:2024-11-16 11:27

Solution to the loss of the first character when the STM32 serial port sends characters for the first time
Most of the codes for sending characters on the Internet are as follows: USART_SendData(USART1, (uint8_t)ch); while( USART_GetFlagStatus(USART1, USART_FLAG_TC) != SET); Actually, it makes sense at first glance, but when I read the manual carefully, I found that the TC and TXE flags are set to 1 when reset, so the firs
[Microcontroller]
【STM32】Nested Vectored Interrupt Controller (NVIC)
        NVIC, Chinese name Nested Interrupt Vector Controller, is a unique integrated unit inside the Cortex-M3 series controller, which is closely integrated with the CPU, reduces interrupt latency and can handle subsequent interrupts more efficiently. For example, when buying tickets at a train station, the rules and
[Microcontroller]
STM32__main code analysis
The STM32 startup code mainly allocates the stack and sets the vector table, and then jumps to the __main function. The specific code segment to jump to is as follows:   view plain   copy Reset_Handler PROC                   EXPORT Reset_Handler                    IMPORT __main                   LDR R0, = __mai
[Microcontroller]
STM32__main code analysis
Output Compare of stm32 timer
STM32F103VB sends a logic signal to MOC3020 to control the on and off of the BTA16 thyristor. When a zero-crossing signal is detected, the output is 1 after a delay of x milliseconds; the output is turned off after a delay of y milliseconds. This can realize phase-controlled speed regulation of induction motors (low p
[Microcontroller]
Output Compare of stm32 timer
In-depth understanding of STM32 memory and bus architecture 1 (based on STM32F411)
This article is reproduced from http://blog.csdn.net/charmingsun/article/details/52258419 Official documentation:  STM32F411 Reference ManualSTM32F411   Data   SheetCortex™-M4F Programming ManualSTM32   Microcontroller System Memory Boot Mode Application NotesUSART   Protocol Used in STM32™ BootloaderARM   Cortex™-M
[Microcontroller]
STMicroelectronics is working with AWS and Microsoft to help STM32U5 enable more secure IoT development
STMicroelectronics is strengthening its collaboration with Amazon (AWS) and Microsoft to expand the Internet of Things. On AWS, ST provides a reference that makes it easier and more secure to connect IoT (Internet of Things) devices (STM32U5) to the AWS cloud. At the same time, STMicroelectronics is working with Micro
[Microcontroller]
STM32 small package PD0, PD1 have no external interrupt function
After suffering a loss, I learned my lesson. I got the board back (another night was gone. Where did the engineer's time go? Most of it was wasted like this. I grew up from these failures). When I couldn't adjust it, I looked at the PDF again and found the following: 7.3.2 Use OSC_IN/OSC_OUT pins as GPIO port PD0/PD
[Microcontroller]
stm32 library function learning chapter general timer input capture function
Function: PA8 can drive the LED light to flash with random delay, and connect PA8 to PA7 port with Dupont line. PA7 is the 2nd channel of general timer TIM3. In the TIM3_CH2 trigger interrupt program, the LED light connected to PD2 port is inverted to indicate the interrupt program is running, and the polarity of trigg
[Microcontroller]
stm32 library function learning chapter general timer input capture function
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号