📄 timer.c
字号:
#include <csl.h>
#include <csl_gpio.h>
#include <stdio.h>
#include "ICETEK-C6713-A.h"
int fLed=0;
int count=0;
static GPIO_Handle hGpio;
main()
{
/* Initialize CSL,must when using CSL. */
CSL_init();
/* Set GPIO. */
hGpio = GPIO_open(GPIO_DEV0,GPIO_OPEN_RESET);
GPIO_reset(hGpio);
GPIO_pinEnable(hGpio,GPIO_PIN13);
GPIO_pinDirection(hGpio,GPIO_PIN13,GPIO_OUTPUT);
InitInterrupt();
while ( 1 )
{
if(1==fLed)
{
GPIO_pinWrite(hGpio,GPIO_PIN13,0);
}
else
{
GPIO_pinWrite(hGpio,GPIO_PIN13,1);
}
Delay(16);
}
}
void InitInterrupt(void)
{
// 设置中断控制寄存器
CSR&=0xfffffffe; // 关中断 GIE=0
ISTP=0x00000c00; // 重置中断向量表到0C00h
IMH=0x08000000; // 指定Timer1产生int15中断
IML=0;
ICR=0xff; // 清除等待的中断
IER=0x8003; // 使能int15中断
// 设置定时器产生中断信号的频率
TIMER1PRD=9999000; // 定时器1的周期=3125000, 0.5s
TIMER1CTL=0x3c0; // 开始计数
CSR=CSR|1; // 开中断
}
void interrupt Timer1() //中断响应函数
{
fLed ^= 1;
//printf("%d..\n",count++);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -