#include<reg51.h>
#include<absacc.h>
#define PA XBYTE [0Xcfa0]
#define PB XBYTE [0Xcfa1]
#define PC XBYTE [0Xcfa2]
unsigned char table1[10]={1,2,3,4,5,6,7,8,9,10 };
unsigned char table2[10]={ 0,0,0,0,0,0,0,0,0,0 };
unsigned char LEDSEG[10]={0X3F,0X06,0X5B,0X4F,0X66,0X6D,0X7D,0X07,0X7F,0X6F}
unsigned char i=0,j=0,k=0;
void Delay (unsigned int u);
void send ();
void recv ();
void display ();
void main ()
{
TMOD=0X20 ;
TH1=TL1=255 ;
TR1=1;
SCON=0x50;
PCON=0x80;
EA=1;ES=1;
while (1)
{
send ();
display ();
}
}
void send ()
{SBUF=table1[i++];
Delay (50);
if (i==10) i=0;
}
void recv()
{table2[j++]=SBUF;
if (j==10) j=0;
}
void display ()
{
if (j!=0)
{P1=table2[k++];
Delay (1000);
if (k==10) k=0;
PB=0xfe;
PA=LEDSEG[table1[10]-0x30];
delay(10);
}
}
void ser () interrupt 4
{
if(TI==1) TI=0;
if(RI==1)
{RI=0;recv ();}
}
void Delay (unsigned int u)
{
unsigned char i;
while (u--)
{for (i=0;i<42;i++);}
}
|