STM32 system clock base timer

Publisher:小牛队Latest update time:2017-09-23 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The STM32F10x core has a system clock base timer, which is a 24-bit down counter. After it is set and enabled, the count value decreases by 1 every time a system clock cycle passes. When the count value decreases to 0, the system time base timer will automatically reload the initial value.

The system time base timer generates an interrupt every 10ms.

Next, we will mainly introduce the library functions.

1. The function of SysTick_CLKSourceConfig is to set the clock source of SysClock. The input parameter is SysTick_CLKSource: SysTick clock source

The possible values ​​of the parameter are: SysTick_CLKSource_HCLK_Div8; SysTick_CLKSource_HCLK. Indicates that the SysTick clock source is the AHB clock divided by 8 and the AHB clock source.

Example: Set the system timer clock to AHB clock.

SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);

2. The function of Sys_SetReload is to set the SysTick reload value. Its input parameter is a value between 32-bit 1 and 0x00FFFFF. (u32 Reload)

Example: Set the reload value of the system timer to 90000.

SysTick_SetReload(900000);

3. The function of SysTick_CounterCmd is to enable or disable the SysTick counter. Its input parameter is SysTick_Counter: the new state of the SysTick counter

The possible values ​​of the parameter are SysTick_Counter_Disable/Enable/Clear. Indicates disable, enable, clear counter value is 0.

Example: Enable the system timer.

SysTick_CounterCmd(SysTick_Counter_Enable);

4. The function of SysTick_ITconfig function is to enable or disable SysTick interrupt.

5. The function of SysTick_GetCounter is to get the value of SysTick counter.

Example: Get the count value of the system timer. It is a 32-bit value.

u32 SysTickCurrentCounterValue;

SysTickCurrentCounterValue = SysTick_GetCounter();


Keywords:STM32 Reference address:STM32 system clock base timer

Previous article:Basic knowledge of STM32 USART
Next article:STM32 system clock initialization program design

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号