?? vectors08.c
字號:
/*-----------------------------------------------------*
*文件名:vectors08.c *
*功 能:用于定義中斷矢量表 *
*-----------------------------------------------------*/
#include "GP32C.H"
#include "KB.h"
#include "TIME.h"
#include "LCD.h"
/*[相應寄存器定義]*/
#define TSTOPBit 5 //定時器計數停止位
#define TOFBit 7 //定時器溢出標志位
/*isrTIMER1:定時器溢出中斷處理函數---------------------*
*功 能:給內存單元Time[0-2](時分秒)賦值 *
*-----------------------------------------------------*/
unsigned char KB_valve;
extern unsigned char time[7]; //H M S
extern unsigned char time1[];
extern unsigned char val;
extern unsigned char val1;
extern unsigned char sign1;
extern unsigned char sign2;
#pragma interrupt_handler isrTIMER1
void isrTIMER1(void)
{
unsigned char i;
unsigned int j;
val=1;
asm("SEI"); //關總中斷
//------------------------------
time[6]++; //秒數加1
if (time[6]!=60) goto isrTIMER1_exit; //秒數未增加到60,轉
time[6]=0; time[5]++; //秒數增加到60,清0,分鐘數加1
if (time[5]!=60) goto isrTIMER1_exit; //分鐘數未增到60,轉
time[5]=0; time[4]++; //分鐘數增加到60,清0,小時數加1
if (time[4]!=24) goto isrTIMER1_exit; //小時數未增到24,轉
time[4]=0; time[3]++; //時數增加到24,清0
i=time[2];
if((time[2]==1)|(time[2]==3)|(time[2]==5)|(time[2]==7)|(time[2]==8)|(time[2]==10)|(time[2]==12))
{
if(time[3]!=31) goto isrTIMER1_exit;
time[3]=0; time[2]++;
}
else if((time[2]==2)|(time[2]==4)|(time[2]==6)|(time[2]==9)|(time[2]==11))
{
if(time[3]!=30) goto isrTIMER1_exit;
time[3]=0; time[2]++;
}
else
{
j=time[0]*100+time[1];
if(((j%4==0)&&(j%100!=0))|(j%400==0))
{
if (time[3]!=29) goto isrTIMER1_exit;
time[3]=0; time[2]++;
}
else
{
if (time[3]!=28) goto isrTIMER1_exit;
time[3]=0; time[2]++;
}
}
/*switch(i)
{
case 2:
j=time[0]*100+time[1];
if(((j%4==0)&&(j%100!=0))|(j%400==0))
{
if (time[3]!=29) goto isrTIMER1_exit;
time[3]=0;
time[2]++;
}
else
{
if (time[3]!=28) goto isrTIMER1_exit;
time[3]=0;
time[2]++;
}
case 4:case 6:case 9:case 11:
if(time[3]!=30)
{
goto isrTIMER1_exit;
}
time[3]=0;
time[2]++;
break;
case 1:case 3:case 5:case 7:case 8:case 10:case 12:
{
if(time[3]!=31)
{
goto isrTIMER1_exit;
}
time[3]=0;
time[2]++;
break;
}
default: break;
}
*/
if (time[2]!=12) goto isrTIMER1_exit;
time[2]=0; time[1]++;
if (time[1]!=99) goto isrTIMER1_exit;
time[1]=0; time[0]++;
isrTIMER1_exit:
T1SC&=~(1<<TOFBit);
asm("CLI"); //開總中斷
}
/*鍵盤中斷處理函數------------------------------------*/
#pragma interrupt_handler isrKBI
void isrKBI(void)
{
asm("SEI"); //關總中斷
INTKBSCR|= (1<<IntBit); //屏蔽鍵盤中斷(IMASKK=1)
//val1=1;
KB_valve=KB_Scan(); //掃描鍵值
// SCISend1(KB_valve);
KB_valve=KB_Def(KB_valve); //鍵值轉化為定義值
if(KB_valve=='A')
{
sign1=1;
//SetTime();
}
if(KB_valve=='B')
{
//SetAlarmClock();
sign2=1;
}
KB_Init(); //重新初始化鍵盤
INTKBSCR&= ~(1<<IntBit); //打開鍵盤中斷(IMASKK=0)
asm("CLI"); //開總中斷
}
/*isrRe:接收中斷處理函數-------------------------------*
*功 能:接收3字節基準時分秒放入內存單元Time[0-2] *
*-----------------------------------------------------*/
/*#pragma interrupt_handler isrRe
void isrRe(void)
{
asm("SEI"); //禁止所有中斷
//接收數據
SCIReN(3,time);
asm("CLI"); //開放總中斷
}
//未定義的中斷處理函數,本函數不能刪除*/
#pragma interrupt_handler isrDummy
void isrDummy(void)
{
}
#pragma abs_address:0xffdc //中斷向量表起始地址
void (* const _vectab[])(void) = {
isrDummy, //時基中斷
isrDummy, //AD轉換中斷
isrKBI, //鍵盤中斷
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
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -