#include<reg51.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit led1=P2^1;
void serialInti();
void delay();
/*chuang kou chu shi han shu*/
void serialInti()
{
TMOD=0X20;
TH1=0Xfd;
TL1=0Xfd;
TR1=1;
SM0=0;
SM1=1;
REN=1;
EA=1;
ES=1;
}
/*yan shi han shu*/
void delay()
{
uchar x,j;
for(j=0;j<2;j++)
for(x=0;x<=148;x++) ;
}
/*zhu han shu*/
void main (void)
{
serialInti();
while(1)
{
}
}
/*chuang kou zhong duan han shu*/
void Serial_interrupt() interrupt 4
{
uchar recivedata ;
EA=0;
if(RI)
{
RI=0;
recivedata=SBUF ;
switch(recivedata)
{
case '1':led1=1;break;
case '0':led1=0;break;
}
}
EA=1;
} |