?? 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; // 清除中斷標(biāo)志
VICVectAddr = 0x00; // 通知VIC中斷處理結(jié)束
}
/////////////////////////////////////////////////////////////////////////////
void Timer1Initialize(void)
{
//定時(shí)器0初始化
T1TC = 0; //set timer1 initialization value
T1PR = 0; //pclk output to timer1 directly
T1MCR = 0x03; // 設(shè)置T1MR0匹配后復(fù)位T1TC,并產(chǎn)生中斷標(biāo)志
T1MR0 = LPC_FPCLK/1000; // 1/1000秒鐘定時(shí)
T1TCR = 0x01; // 啟動(dòng)定時(shí)器
//設(shè)置定時(shí)器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)
{
//定時(shí)器0初始化
T1TC = 0; //set timer1 initialization value
T1PR = 0; //pclk output to timer1 directly
T1TCR = 0x01; /* 啟動(dòng)定時(shí)器 */
}
/////////////////////////////////////////////////////////////////////////////
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;
// 定時(shí)器0初始化
IRQDisable();
T1TC = 0; //set timer1 initialization value
T1PR = 0; //pclk output to timer1 directly
T1TCR = 0x01; //啟動(dòng)定時(shí)器
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 //
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -