How to use SysTick of STM32F103

Publisher:collectorsLatest update time:2018-07-20 Source: eefocusKeywords:STM32F103 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Write it down for later use.

void SysTick_Configuration(void)
{
  /* Setup SysTick Timer for 10 msec interrupts */
  if (SysTick_Config(SystemCoreClock / 100)) //SysTick configuration function
  { 
    /* Capture error */ 
    while (1);
  }  
 /* Configure the SysTick handler priority */
  NVIC_SetPriority(SysTick_IRQn, 0x0); //SysTick interrupt priority setting
}
The key lies in the understanding of SysTick_Config(SystemCoreClock / 100)

The function is to open the counter, set the counting period, and enable interrupt. The parameter passed in is the counting period.

The cycle calculation method is: By default, the processor will call SystemInit() during initialization and set the system frequency to 72Mhz, that is, SystemCoreClock=72000000;

          It can be simply understood that the system counts 72000000 times per second. If I need a 10ms timing period, I only need to set the reload number to 720000 to meet the requirement.

NVIC_SetPriority(SysTick_IRQn, 0x0); Set the priority to the highest, and adjust it according to your needs

 

Finally, enter the interrupt processing function

void SysTick_Handler(void)
{
   
}


Keywords:STM32F103 Reference address:How to use SysTick of STM32F103

Previous article:STM32 SysTick timer delay function
Next article:Detailed explanation of STM32 system clock settings

Recommended ReadingLatest update time:2024-11-16 15:50

Solution to the CPU could not be halted problem on STM32F103
Problem Description: **JLink Warning: CPU could not be halted ***JLink Error: Can not read register 15 (R15) while CPU is running ***JLink Error: Can not read register 16 (XPSR) while CPU is running ***JLink Error: Can not read register 0 (R0) while CPU is running ***JLink Error: Can not read register 1 (R1) while
[Microcontroller]
Communication between STM32F103 and MCGS
Combining the first two blog posts will allow STM32F103 and MCGS to communicate with each other using the Modbus protocol. On the touch screen: The input box is associated with a numeric object This numeric object is written only 4WUB0000 at the device channel In the input box, you can select the value you want to sen
[Microcontroller]
Communication between STM32F103 and MCGS
Experience of using STM32f103 serial port interrupt through library functions
There are several main steps for STM32 to use USART interrupts: 1. Define the interrupt structure and serial port structure 2. Enable the clock 3. Write interrupt function 4. Enable interrupt Regarding the sending interrupt, the author had a doubt at the time: The above figure is about the two bits in the
[Microcontroller]
Experience of using STM32f103 serial port interrupt through library functions
STM32 SysTick routine
#include "stm32f10x.h"   /*RCC clock configuration*/ void RCC_config() {  ErrorStatus HSEStartUpStatus;   /* RCC registers are set to default configuration */ RCC_DeInit(); /* Turn on external high speed clock */ RCC_HSEConfig(RCC_HSE_ON); /* Wait for the external high-speed clock to stabilize*/ HSEStartUpStat
[Microcontroller]
ADC multi-channel acquisition program for STM32f103 digital electrical acquisition circuit
STM32 has 1~3 ADCs (STM32F101/102 series has only 1 ADC), which can be used independently or in dual mode (increasing the sampling rate). The ADC of STM32 is a 12-bit successive approximation analog-to-digital converter. It has 18 channels and can measure 16 external and 2 internal signal sources. The A/D conversion o
[Microcontroller]
ADC multi-channel acquisition program for STM32f103 digital electrical acquisition circuit
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号