|
大家帮忙看看这段关于偶校验的代码有什么问题,谢谢!
[复制链接]
#include
#include
#define uchar unsigned char
#define uint unsigned int
#define ERR 0;
#define RIGHT 1;
uchar idata sbuf;
void send(unsigned idata receive);
main(){
IE=0; //关闭所有中断
SCON=0xC0; //SM0 SM1 SM2 REN TB8 RB8 TI RI 工作于模式3
PCON=0x00; //SET SMOD=0
TMOD=0x20; //GATE C1/T1 M1 M0 GATE C2/T2 M1 M0 T1 工作于模式2
TH1=0xE8;
TL1=0xE8; //BaudRate=1200
IP=0X08; //T1 is high priority //x x PT2 PS PT1 PX1 PT0
IE=0X98; //EA ES ET1 EX1 ET0 EX0
TR1=1; //T1开始计时
RI=0;
TI=0;
REN=1; //允许接受串行数据
while(1){
if(RI==1)
{
RI=0;
ACC=SBUF;
if (RB8==P)
{sbuf=ACC;}
else
{sbuf=0xFF;}
send(sbuf);
}
}
}
void send(unsigned idata receive){
TI=0;
ACC=receive;
TB8=P;
SBUF=ACC;
while(!TI);
TI=0;
}
|
|