?? vectors08.c
字號(hào):
/*-----------------------------------------------------*
*文件名:vectors08.c *
*功 能:用于定義中斷矢量表 *
*-----------------------------------------------------*/
#include "GP32C.H"
#include "KB.h"
/*[相應(yīng)寄存器定義]*/
#define TSTOPBit 5 //定時(shí)器計(jì)數(shù)停止位
#define TOFBit 7 //定時(shí)器溢出標(biāo)志位
//外部變量
extern unsigned char time[14]; //H M S
extern unsigned char Key;
/*isrTIMER1:定時(shí)器溢出中斷處理函數(shù)---------------------*
*功 能:給內(nèi)存單元Time[0-2](時(shí)分秒)賦值 *
*-----------------------------------------------------*/
#pragma interrupt_handler isrTIMER1
void isrTIMER1(void)
{
unsigned char i;
asm("SEI"); //關(guān)總中斷
//------------------------------
time[13]++; //秒數(shù)加1
if (time[13]!=10) goto isrTIMER1_exit; //秒數(shù)未增加到60,轉(zhuǎn)
time[13]=0; time[12]++; //秒數(shù)增加到60,清0,分鐘數(shù)加1
if (time[12]!=6) goto isrTIMER1_exit; //分鐘數(shù)未增到60,轉(zhuǎn)
time[12]=0; time[11]++; //分鐘數(shù)增加到60,清0,小時(shí)數(shù)加1
if (time[11]!=10) goto isrTIMER1_exit; //小時(shí)數(shù)未增到24,轉(zhuǎn)
time[11]=0; time[10]++; //時(shí)數(shù)增加到24,清0
if(time[10]!=6) goto isrTIMER1_exit;
time[10]=0;time[9]++;
if(time[9]!=10) goto isrTIMER1_exit;
time[9]=0;time[8]++;
if(time[8]!=3) goto isrTIMER1_exit;
time[8]=0;time[7]++;
if(time[7]!=10) goto isrTIMER1_exit;
time[7]=0;time[6]++;
if(time[6]!=3) goto isrTIMER1_exit;
time[6]=0;time[5]++;
if(time[5]!=10) goto isrTIMER1_exit;
time[5]=0;time[4]++;
if(time[4]!=2) goto isrTIMER1_exit;
time[4]=0;time[3]++;
if(time[3]!=10) goto isrTIMER1_exit;
time[3]=0;time[2]++;
if(time[2]!=10) goto isrTIMER1_exit;
time[2]=0;time[1]++;
if(time[1]!=10) goto isrTIMER1_exit;
time[1]=0;time[0]++;
if(time[0]!=10) goto isrTIMER1_exit;
time[0]=0;
isrTIMER1_exit:
//------------------------------
//清除定時(shí)器溢出標(biāo)志位
T1SC&=~(1<<TOFBit);
asm("CLI"); //開(kāi)總中斷
}
/*鍵盤(pán)中斷處理函數(shù)------------------------------------*/
#pragma interrupt_handler isrKBI
void isrKBI(void)
{
unsigned char KB_valve;
asm("SEI"); //關(guān)總中斷
INTKBSCR|= (1<<IntBit); //屏蔽鍵盤(pán)中斷(IMASKK=1)
KB_valve=KB_Scan(); //掃描鍵值
Key=KB_Def(KB_valve); //獲得鍵定義值,通過(guò)另Key為外部變量來(lái)實(shí)現(xiàn)數(shù)值傳遞
KB_Init(); //重新初始化鍵盤(pán)
INTKBSCR&= ~(1<<IntBit); //打開(kāi)鍵盤(pán)中斷(IMASKK=0)
asm("CLI"); //開(kāi)總中斷
}
//未定義的中斷處理函數(shù),本函數(shù)不能刪除
#pragma interrupt_handler isrDummy
void isrDummy(void)
{
}
#pragma abs_address:0xffdc //中斷向量表起始地址
void (* const _vectab[])(void) = {
isrDummy, //時(shí)基中斷
isrDummy, //AD轉(zhuǎn)換中斷
isrKBI, //鍵盤(pán)中斷
isrDummy, //SCI TC/TE
isrDummy, //SCI RF/IDLE
isrDummy, //SCI PE/FE/NF/OR
isrDummy, //SPI TE
isrDummy, //SPI MOD/OVR/RF
isrDummy, //TIM2溢出中斷
isrDummy, //TIM2通道1
isrDummy, //TIM2通道0
isrTIMER1, //TIM1溢出中斷
isrDummy, //TIM1通道1
isrDummy, //TIM1通道0
isrDummy, //CGM
isrDummy, //IRQ
isrDummy //SWI
//RESET也是中斷,定義在 crt08.o中
};
#pragma end_abs_address
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -