【stm32f103】SysTick delay implementation (register version)

Publisher:乐基儿vosLatest update time:2019-01-31 Source: eefocusKeywords:stm32f103  SysTick  Delay Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Introduction to SysTick Register

For SysTick, please refer to the Programming manual. There are 4 registers in total, as shown in the figure:

They are STK_CTRL

STK_LOAD


STK_VAL


STK_CALIB calibration, this is basically not used, or the level is not up to that level, so it is not used for the time being


2. Program Analysis

Delay_us


void Delay_us(unsigned int nTime)

{

         SysTick->LOAD = 72*nTime;

         SysTick->CTRL =SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_CLKSOURCE_Msk;

         while(!(SysTick->CTRL&SysTick_CTRL_COUNTFLAG_Msk));

         SysTick->CTRL =~SysTick_CTRL_ENABLE_Msk;

}


The delay of us is completed until bit 16 is 1. Because systick is only a 24-bit counter, there is always a maximum delay, so delay ms is used to achieve more delay.


void Delay_ms(unsigned int nTime)

{

for(;nTime > 0;nTime--)

                   Delay_us(1000);

}

The above can achieve delay and the test is effective


Keywords:stm32f103  SysTick  Delay Reference address:【stm32f103】SysTick delay implementation (register version)

Previous article:【stm32f103】USART TX transmission implementation (register version)
Next article:【stm32f103】Use of TIMER basic timing function (register version)

Latest Microcontroller Articles
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号