interrupt.c
来自「单片机的主控端」· C语言 代码 · 共 80 行
C
80 行
#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 + =
减小字号Ctrl + -
显示快捷键?