⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 systick.c

📁 周立功LM3S8962开发板提供的 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:          V1.1
** Descriptions:            利用系统定时器产生1秒的定时,实现LED的翻转
**
**--------------------------------------------------------------------------------------------------------
** Created by:              Zhao shimin
** Created date:            2007.09.16
** Version:                 V1.0
** Descriptions:            The original version
**
**--------------------------------------------------------------------------------------------------------
** Modified by:             Kang qinhua
** Modified date:           2008.01.12
** Version:                 V1.1
** 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)
{
    
    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_6MHZ);
                                                                        /*  设置系统时钟为直接使用外部  */
                                                                        /*  晶体的频率6MHz           */
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);                        /*  给GPIOD提供时钟             */    
    
    GPIOPadConfigSet(GPIO_PORTA_BASE, LED6 ,GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
                                                                        /*  设置GPIO7为推挽,2MA输出    */
    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 + -