📄 interrupt.c
字号:
#include "sys.h"
extern data UCHAR *p;
extern UCHAR UIData[6];
extern bit receiveFlag;
extern bit responseFlag;
extern bit sendFlag;
void int0() interrupt 0
{
//todo
}
void timer0() interrupt 1
{
static UCHAR n;
TH0 = 0;
TL0 = 0;
n++;
if(n == 5)
{
n = 0;
TR0 = 0;
TH0 = 0;
TL0 = 0;
responseFlag = 1;
}
}
void int1() interrupt 2
{
//todo
}
void timer1() interrupt 3
{
//todo
}
void serial() interrupt 4
{
static UCHAR temp = 0;
if(RI) //the receive process
{
RI = 0;
if(RB8) //receive the address
{
temp = SBUF;
if(temp == LOCALCELL)
SM2 = 0;
temp = 0;
}
else //receive the data
{
UIData[temp++] = SBUF;
if(temp == 6)
{
SM2 = 1;
receiveFlag = 1;
TR0 = 0; //receive the response,close the timer0
TH0 = 0;
TL0 = 0;
temp = 0;
}
}
}
else if(TI && (temp < 2))
{
TB8 = 0; //sign data flag
TI = 0;
SBUF = *p;
temp++;
}
else if(TI)
{
TI = 0;
temp = 0;
sendFlag = 1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -