#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar x,y,face,a,b;
uchar i=0;
uchar shuzu[8][8];
/*uchar shuzu[8][8]={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18,
0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18,
0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, };
//显示固定图案,数组可任意改动 // */
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=10;y>0;y--);
}
void init()
{
TMOD=0x22;
TH1=0XFf; //波特率设置,波特率为57600
TL1=0XFf;
TH0=0x00;
TL0=0x00;
TR1=1;
TR0=1;
SCON=0X50;
PCON|=0x80;
EA=1;
ES=1;
ET0=1;
PS=1; //让串口中断优先,设置优先级高些
}
void main()
{
b=0;
init();
while(1)
{
}
}
void rxd()
interrupt 4
{
uchar temp=0;
RI=0;
++b;
if(b>=8) //上位机中发数据的时候,前面一个不变的地址码,
//要去掉,故到2的时候才存数据
{
temp=SBUF;
shuzu[x][y]=temp;//把数据存到数组中
x++; if(x>=8) //一列一列存
{
x=0;
y++;
if(y>=8)
y=0;
}
}
if(b>=65) //到65,64个数据接收完毕
b=0;
}
void timer0_isr(void)
interrupt 1 //把数组取出来,送给锁存器、三极管基极
{
for (i=0;i<7;i++)
{
P2|=(0x01<<i); //573使能端
P0=~(shuzu[face][i]);//573数据输入端
P2&=~(0x01<<i); //delay(20); }
P3=0X03; // P3=~(0x01<<face); //面选择端(八个面分别的公共端) //不要加(taf)
if(face<7)
face++;
else
face=0;
}
}
|