STM32 Getting Started with SysTick System Timer (STM32F030F4P6 based on CooCox IDE)

Publisher:未来感觉Latest update time:2018-07-10 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

#include "stm32_lib/inc/stm32f0xx_misc.h"

#include "stm32_lib/inc/stm32f0xx_rcc.h"

 

int main(void){

//Configure the initial value, the system timer is a countdown timer, minus 1

//Note: Although the parameter type of this function is uinit32_t, the actual maximum value is 16777215, which is 2^24

SysTick_Config(SystemCoreClock/10);

while(1);

}

//Interrupt function

void SysTick_Handler(void){

//Do what you want here

}

System timer, it's that simple! The clock is the system clock, just configure the countdown number.

Please note that the effective value of the counter is 24 bits. If you set it to SystemCoreClock/2, you will be in trouble!

看图 if (ticks > SysTick_LOAD_RELOAD_Msk)  return (1);

What is SysTick_LOAD_RELOAD_Msk? 0xFFFFFFUL << 0. Got it!

By the way, interrupts do not need to be configured by the user because the system has configured them for you.



What's so good about this system clock?

Personally, I only think of using it for flashing various LEDs. I throw the flashing task to SysTick_Handler, and the main program can do whatever it wants.


Keywords:STM32 Reference address:STM32 Getting Started with SysTick System Timer (STM32F030F4P6 based on CooCox IDE)

Previous article:STM32F030F4P6 Flash capacity problem
Next article:stm32f030c8t6 MCU enters low power mode

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

Several methods of measuring frequency and duty cycle using STM32
Platform used: official STM32F429DISCOVERY development board, 180MHz main frequency, timer frequency 90MHz. Related topics: (1) Measure the pulse signal frequency f_O in the frequency range of 10Hz to 2MHz, and the absolute value of the measurement error is no more than 0.1%. (15 points) (2) Measure the duty cycle D o
[Microcontroller]
Several methods of measuring frequency and duty cycle using STM32
Detailed explanation of two methods of STM32 PWM capture
Preface:             The capture PWM wave of STM32's TIM is for frequency and duty cycle, these two data results! Its most basic principle is (for example): for example, when a high-level rising edge comes, the captured value is the count value of the TIM that rises to a high level (TIM timer, CNT keeps increasing and
[Microcontroller]
Detailed explanation of two methods of STM32 PWM capture
About the selection of stm32 startup file
- startup_stm32f10x_ld_vl.s: for STM32 Low density Value line devices - startup_stm32f10x_ld.s: for STM32 Low density devices - startup_stm32f10x_md_vl.s: for STM32 Medium density Value line devices - startup_stm32f10x_md.s: for STM32 Medium density devices - startup_stm32f10x_hd. s: for STM32 High density devices
[Microcontroller]
STM32: DAC configuration and use
DAC Introduction DAC means digital-to-analog conversion. The DAC module consists of three parts: "trigger selection", "control logic" and "digital-to-analog converter". Among them, "trigger selection" and "digital-to-analog converter" are necessary modules for DAC conversion, and the "control logic" module contains th
[Microcontroller]
STM32: DAC configuration and use
Porting FATFS for STM32 to read FAT12/16/32 file system on SD card
Transplanting fatfs file system to stm32, finally achieved a phased victory today. Only a few functions need to be provided:  DSTATUS disk_initialize (BYTE);  DSTATUS disk_status (BYTE);  DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE);  DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE); // If a read-only file system i
[Microcontroller]
Solution to the "Internal command error" error in STM32 that prevents the program from being downloaded
method one: Options for target-- Debug-- settings on the right--- Connect & Reset option in the Debug column, change Nornal to With pre-reset. Effect: Sometimes it works, sometimes it doesn't. Method Two: If there is a reset button, press and hold it, then click the program download/debug button in Keil, and r
[Microcontroller]
STM32 simulation IIC program
    #ifndef __AT24C02_H__     #define __AT24C02_H__     #include"stm32f10x.h"     void i IC init(void);     void iicwrite(u8 add,u8 Achar);       u8 iicread(u8 add);     #endif     #include"stm32f10x.h"     #include"at24c02.h"     void iicstart(void);     void iicstop(void);     void ack(void);     void iicwritebyte(u
[Microcontroller]
STM32 IDLE interrupt
Today, let's talk about how to receive indefinite length byte data on the STM32 microcontroller. Since the STM32 microcontroller has an IDLE interrupt, you can use this interrupt to receive indefinite length byte data. Since the STM32 is an ARM microcontroller, the method in this article is also suitable for other ARM
[Microcontroller]
STM32 IDLE interrupt
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号