📄 user_systick.c
字号:
/****************************************Copyright (c)**************************************************
** 思 蜕 盟 豆 皮 开 发 小 组
** stmfans 论坛
**
** QQ 群: 65081316 StmFans思蜕盟 1组
** QQ 群: 68584951 StmFans思蜕盟 2组
** http://www.stmfans.com/bbs/
**
** This program was produced by the
** IAR Embedded Workbench 4.0 Kickstart 442
** Copyright 2008-2009 stmfans
** Chip type : STM32F103VB
** Program type : Application
** Clock frequency : 8.000000 MHz
** Memory model :
** External SRAM size :
** Data Stack size :
**--------------文件信息--------------------------------------------------------------------------------
**文 件 名: user_systick.c
**创 建 人: 陈海
**最后修改日期: 2008年10月23日
**描 述: 豆皮开发板教程
**
**--------------历史版本信息----------------------------------------------------------------------------
** 创建人: 陈海
** 版 本: v0.01
** 日 期: 2008年10月23日
** 描 述: 原始版本
**
**--------------当前版本信息----------------------------------------------------------------------------
** 创建人: 陈海
** 版 本: v0.01
** 日 期: 2008年10月23日
** 描 述: 当前版本
**
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
#include "user_systick.h"
/*******************************************************************************
* Function Name : SysTick_Config
* Description : Configures SysTick
* Input : None
* Output : None
* Return : None
*******************************************************************************/
//SysTick设置
void SysTick_Config(void)
{
/* Disable SysTick Counter */
SysTick_CounterCmd(SysTick_Counter_Disable);
/* Disable the SysTick Interrupt */
SysTick_ITConfig(DISABLE);
/* Configure HCLK clock as SysTick clock source */
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);
/* SysTick interrupt each 1000 Hz with HCLK equal to 72MHz */
SysTick_SetReload(9000);
/* Enable the SysTick Interrupt */
SysTick_ITConfig(ENABLE);
}
/*******************************************************************************
* Function Name : Delay_Ms
* Description : Inserts a delay time.
* Input : nTime: specifies the delay time length, in milliseconds.
* Output : None
* Return : None
*******************************************************************************/
void Delay_Ms(u32 nTime)
{
/* Enable the SysTick Counter */
SysTick_CounterCmd(SysTick_Counter_Enable);
TimingDelay = nTime;
while(TimingDelay != 0);
/* Disable SysTick Counter */
SysTick_CounterCmd(SysTick_Counter_Disable);
/* Clear SysTick Counter */
SysTick_CounterCmd(SysTick_Counter_Clear);
}
/*******************************************************************************
* Function Name : TimingDelayMs_Decrement
* Description : Decrements the TimingDelay variable.
* Input : None
* Output : TimingDelay
* Return : None
*******************************************************************************/
void TimingDelay_Decrement(void)
{
// this code is for delay ms /////////////////////
if (TimingDelay != 0x00)
{
TimingDelay--;
}
/////////////////////////////////////////////////////
// this code is for count /////////////////////////
ClickCounter++ ;
}
void Start_Count_Click(void)
{
/* Enable the SysTick Counter */
SysTick_CounterCmd(SysTick_Counter_Enable);
// init the count register
ClickCounter = 0;
}
void Stop_Count_Click(void)
{
/* Disable SysTick Counter */
SysTick_CounterCmd(SysTick_Counter_Disable);
/* Clear SysTick Counter */
SysTick_CounterCmd(SysTick_Counter_Clear);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -