📄 systick.c
字号:
/****************************************Copyright (c)****************************************************
** Guangzhou ZHIYUAN electronics Co.,LTD.
**
** http://www.embedtools.com
**
**--------------File Info---------------------------------------------------------------------------------
** File name: SysTick.c
** Latest modified Date: 2007-09-16
** Latest Version: 1.1
** Descriptions: 利用系统定时器产生1秒的定时,实现LED的翻转
**
**--------------------------------------------------------------------------------------------------------
** Created by: Zhao shimin
** Created date: 2007-09-16
** Version: 1.0
** Descriptions: The original version
**
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
*********************************************************************************************************/
/* 调用库函数的头文件 */
#include "hw_memmap.h"
#include "hw_types.h"
#include "hw_ints.h"
#include "gpio.h"
#include "interrupt.h"
#include "sysctl.h"
#include "systick.h"
#define LED6 GPIO_PIN_5 /* PA5 */
/*********************************************************************************************************
** Function name: main
**
** Descriptions: 利用系统定时器产生1秒的定时,翻转LED
**
** input parameters: NONE
** output parameters: NONE
**
** Returned value: NONE
**
** Created by: Zhao shimin
** Created Date: 2007/09/16
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
int main (void)
{
/* 设置系统时钟为直接使用外部晶体的频率6MHz */
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_6MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); /* 给GPIOD提供时钟 */
/* 设置GPIO7为推挽,2MA输出 */
GPIOPadConfigSet(GPIO_PORTA_BASE, LED6 ,GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
GPIODirModeSet(GPIO_PORTA_BASE,LED6 ,GPIO_DIR_MODE_OUT); /* 设置GPIOD7为输出 */
IntMasterEnable(); /* 开放总中断 */
SysTickPeriodSet(6000000); /* 设置定时周期为1秒,即6M */
SysTickEnable(); /* 系统定时器使能 */
SysTickIntEnable(); /* 系统定时器中断使能 */
while (1) {
;
}
}
/*********************************************************************************************************
** Function name: SysTick_ISR
**
** Descriptions: 系统定时器中断函数,翻转LED
**
** input parameters: NONE
** output parameters: NONE
**
** Returned value: NONE
**
** Created by: Zhao shimin
** Created Date: 2007/09/16
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
void SysTick_ISR (void)
{
GPIOPinWrite(GPIO_PORTA_BASE,LED6, ~GPIOPinRead(GPIO_PORTA_BASE, LED6));
}
/*********************************************************************************************************
END FILE
*********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -