|
#include "reg51.h"
typedef unsigned char u8;
typedef unsigned int u16;
sbit led=P2^0;
u8 i;
void UsartInit()
{
TMOD=0X20;
TH1=0xF3;
TL1=0xF3;
PCON=0x80;
TR1=1;
SCON=0x50;
ES=1;
EA=1;
}
void main()
{
UsartInit();
while(1);
}
void Usart() interrupt 4
{
u8 receiveDate=SBUF;
RI=0;
i=SBUF;
switch(i)
{
case(1):led=0;break;
}
SBUF=receiveDate;
while(!TI);
TI=0;
}
|
|