初学者,大家可以帮忙解释下这段代码嘛
#include <reg51.h>
#define uchar unsigned char
#define NODE1_ADDR 1
#define NODE2_ADDR 2
uchar KeyValue=0;
uchar code str[]="0123456789ABCDEF";//将定义的数据放入rom
uchar pointer_1=0,pointer_2=0;
void delay(uchar time)
{
uchar i,j;
for(i=0;i<130;i++)
for(j=0;j<time;j++);
}
void proc_key(uchar node_number)
{
delay(200);
SCON=0xc0;//串口初始化
TMOD=0x20;
TH1=TL1=0xfd;
TR1=1;
TB8=1;
SBUF=node_number;//发送数据
while(TI==0);
TI=0;
TB8=0;
switch(node_number)
{
case 1:
{
SBUF=str[pointer_1++];
if(pointer_1>=16)
pointer_1=0;
break;
}
case 2:
{
SBUF=str[pointer_2++];
if(pointer_2>=16)
pointer_2=0;
break;
}
default:break;
while(TI==0);
TI=0;
}
}
void main(void)
{
while(1)
{
P1=0xff;
while(P1==0xff);
switch(P1)
{
case 0xfe:proc_key(NODE1_ADDR);break;
case 0xef:proc_key(NODE2_ADDR);break;
}
}
} |