📄 recesive.c
字号:
#include <AT89x051.H>
unsigned long check;
unsigned char ok;
unsigned char receivebits;
unsigned char receivebytes;
unsigned char recedata;
unsigned char start;
int i;
int j;
void main(void)
{
check=0;
SP=0X59;
P3_0=1;
EX0=1;
IT0=1;
EA=1;
ok=0;
while(1)
{
P3_1=1;
P3_1=0;
if(ok==1)
{
if((recedata&0x01)==0x01)
P3_3=0;
else
P3_3=1;
if((recedata&0x02)==0x02)
P3_4=0;
else
P3_4=1;
if((recedata&0x04)==0x04)
P3_5=0;
else
P3_5=1;
if((recedata&0x08)==0x08)
P3_7=0;
else
P3_7=1;
ok=0;
}
}
}
receivedata() interrupt 0 using 3
{
if(start==0)
{
check=check<<1;
if(P3_0==1)
check++;
if(check==0x99887766)
start=1;
}
else
{
receivebits++;
recedata=recedata<<1;
if(P3_0==1)
recedata++;
if(receivebits==8)
{
receivebits=0;
start=0;
ok=1;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -