📄 drv_timer1.c
字号:
#include "config_GD61.h"
#include "include_GD61.h"
#include <stdio.h>
#include <math.h>
/////////////////////////////////////////////////////////////////////////////
void __irq IRQ_Timer1Serving (void);
void Timer1Initialize(void);
void TimeElapseStart(void);
void TimeElapseStop(char *titlePt,uint32 usTimeFilter);
void DelayUS_(uint32 dly);
/*
/////////////////////////////////////////////////////////////////////////////
void __irq IRQ_Timer1Serving(void)
{
//do something here.
T1IR = 0x01; // 清除中断标志
VICVectAddr = 0x00; // 通知VIC中断处理结束
}
/////////////////////////////////////////////////////////////////////////////
void Timer1Initialize(void)
{
//定时器0初始化
T1TC = 0; //set timer1 initialization value
T1PR = 0; //pclk output to timer1 directly
T1MCR = 0x03; // 设置T1MR0匹配后复位T1TC,并产生中断标志
T1MR0 = LPC_FPCLK/1000; // 1/1000秒钟定时
T1TCR = 0x01; // 启动定时器
//设置定时器0中断IRQ
VICVectCntl8 = 0x20|INT_TIMER1; //enable the int vector and assign the priority of int.
VICVectAddr8 = (uint32)IRQ_Timer1Serving; //assign the address of int handler.
VICIntEnable = 1<<INT_TIMER1; //
}
*/
/////////////////////////////////////////////////////////////////////////////
void TimeElapseStart(void)
{
//定时器0初始化
T1TC = 0; //set timer1 initialization value
T1PR = 0; //pclk output to timer1 directly
T1TCR = 0x01; /* 启动定时器 */
}
/////////////////////////////////////////////////////////////////////////////
void TimeElapseStop(char *titlePt,uint32 usTimeFilter)
{
char dbuffer[100];
uint32 buff;
T1TCR = 0x00; /* stop timer1*/
buff = T1TC;
buff = buff*100/1106 + buff*8/1106/1106; //11.0592
if(buff>usTimeFilter){
sprintf(dbuffer,"%s elapsed time: %d us = %d ms",titlePt,buff,((buff+500)/1000));
Uart0SendString(dbuffer);
}
}
/////////////////////////////////////////////////////////////////////////////
/*
void DelayUS_(uint32 dly)
{
uint32 us_buff;
// 定时器0初始化
IRQDisable();
T1TC = 0; //set timer1 initialization value
T1PR = 0; //pclk output to timer1 directly
T1TCR = 0x01; //启动定时器
IRQEnable(); // 使能IRQ中断
// test timer counter.
do{
us_buff = T1TC;
us_buff = us_buff*100/1106 + us_buff*8/1106/1106; //11.0592
}while(us_buff<dly);
}
*/
////////////////////////////////////////////////////////////////////////////
// end of file //
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -