?? vectors08.c
字號(hào):
/*-----------------------------------------------------*
*文件名:vectors08.c *
*功 能:用于定義中斷矢量表 *
*-----------------------------------------------------*/
#include "GP32C.H"
#include "SCI.h" //串行通信頭文件
#include "KB.h"
/*[相應(yīng)寄存器定義]*/
#define TSTOPBit 5 //定時(shí)器計(jì)數(shù)停止位
#define TOFBit 7 //定時(shí)器溢出標(biāo)志位
/*isrTIMER1:定時(shí)器溢出中斷處理函數(shù)---------------------*
*功 能:給內(nèi)存單元Time[0-2](時(shí)分秒)賦值 *
*-----------------------------------------------------*/
extern unsigned char time[3], naozhong,KB_valve; //H M S
extern unsigned int data[3];
extern unsigned char alart[2];
unsigned char flat=0,f1=0,f2=0;
unsigned char getmonthdays(unsigned int year,unsigned char month)/*得到某月的天數(shù)*/
{
unsigned char days;
switch (month)
{
case 4:
case 6:
case 9:
case 11:days=30;
break;
case 2: if((year%4==0&&year%100!=0)||(year%400==0)) days=29;
else days=28;
break;
default:days=31;
break;
}
return days;
}
#pragma interrupt_handler isrTIMER1
void isrTIMER1(void)
{
unsigned char i;
asm("SEI"); //關(guān)總中斷
//------------------------------
if(((time[0]==0)&&(time[1]==0))||((time[1]==alart[0])&&(time[2]==alart[0])))naozhong=1;
time[0]++; //秒數(shù)加1
if (time[0]!=60) goto isrTIMER1_exit; //秒數(shù)未增加到60,轉(zhuǎn)
time[0]=0; time[1]++; //秒數(shù)增加到60,清0,分鐘數(shù)加1
if (time[1]!=60) goto isrTIMER1_exit; //分鐘數(shù)未增到60,轉(zhuǎn)
time[1]=0; time[2]++; //分鐘數(shù)增加到60,清0,小時(shí)數(shù)加1
if (time[2]!=24) goto isrTIMER1_exit; //小時(shí)數(shù)未增到24,轉(zhuǎn)
time[2]=0; data[0]++; //時(shí)數(shù)增加到24,清0,日期增1
if(data[0]!=getmonthdays(data[2],data[1])) goto isrTIMER1_exit; //天數(shù)數(shù)未增到月尾值,轉(zhuǎn)
data[0]=0;data[1]++; //天數(shù)增加到月尾值,清0,月數(shù)加1
if(data[1]!=13)goto isrTIMER1_exit; //月數(shù)增加未增加到12,轉(zhuǎn)
data[1]=0;data[2]++; //月數(shù)增加到12,清0,年數(shù)加1
isrTIMER1_exit:
//------------------------------
//清除定時(shí)器溢出標(biāo)志位
T1SC&=~(1<<TOFBit);
asm("CLI"); //開總中斷
}
/*isrRe:接收中斷處理函數(shù)-------------------------------*
*功 能:接收3字節(jié)基準(zhǔn)時(shí)分秒放入內(nèi)存單元Time[0-2] *
*-----------------------------------------------------*/
#pragma interrupt_handler isrRe
void isrRe(void)
{
asm("SEI"); //禁止所有中斷
//接收數(shù)據(jù)
SCIReN(3,time);
asm("CLI"); //開放總中斷
}
/*鍵盤中斷處理函數(shù)------------------------------------*/
#pragma interrupt_handler isrKBI
void isrKBI(void)
{
asm("SEI"); //關(guān)總中斷
INTKBSCR|= (1<<IntBit); //屏蔽鍵盤中斷(IMASKK=1)
KB_valve=KB_Scan(); //掃描鍵值
KB_valve=KB_Def(KB_valve); //鍵值轉(zhuǎn)化為
isrKBI_exit:
KB_Init(); //重新初始化鍵盤
INTKBSCR&= ~(1<<IntBit); //打開鍵盤中斷(IMASKK=0)
asm("CLI"); //開總中斷
}
//未定義的中斷處理函數(shù),本函數(shù)不能刪除
#pragma interrupt_handler isrDummy
void isrDummy(void)
{
}
#pragma abs_address:0xffdc //中斷向量表起始地址
void (* const _vectab[])(void) = {
isrDummy, //時(shí)基中斷
isrDummy, //AD轉(zhuǎn)換中斷
isrKBI, //鍵盤中斷
isrDummy, //SCI TC/TE
isrRe, //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
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -