是关于点阵广告牌设计的,有上位机和下位机
#include <reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit H1=P1^0;
sbit H2 =P1^1;
sbit LATCH_L =P1^2;
sbit OUT_L =P1^3;
sbit DS_H =P1^4;
sbit DS_L =P1^5;
void display();
void rxd_data();
void in_data();
void RXD_232();
void INIT();
uchar xdata TABLE[1500];
uchar BUFF[6];
uint ROW=0xfffe;
bit ks_bit;
uint second;
uchar s;
uint temp,
time,nib;
uchar num,left,cc;
uint count;
bit xz_bit;
uint num_int,num1_int;
void delay(uint z)
{
while(z--);
}
void main()
{
uchar clean;
INIT();
while(1)
{
if(xz_bit)
if(second++>=1000)
{
ks_bit=1;second=0;xz_bit=0;num_int=0;num1_int=0;
for(clean=0;clean<64;clean++)
{
TABLE[(count-5)+clean+49]=0x00;
}
}
if(ks_bit)
display();
}
}
void INIT()
{
TMOD=0x21;
TH0=0xfc;
TL0=0x18;
TH1=0xfd;
TL1=0xfd;
EA=1;
TR0=1;
ET0=1;
TR1=1;
SM0=0;
SM1=1;
REN=1;
ES=1;
}
void RXD_232()
{
if(RI)
{
second=0;
if(ks_bit)
{
nib=0;
s=0;num=0;
cc=0;
ROW=0xfffe;
left=0;
P0=255;
H2=H1=1;
H2=H1=0;
count=0;
}
ks_bit=0;
if(count++>=5)
{
if(((count-5)*2)>=num_int&&((count-5)*2)<num_int+32)
TABLE[((count-5)*2+64)-(num1_int)]=SBUF;
if((count-5)*2>=32+num_int&&(count-5)*2<64+num_int)
TABLE[(((count-5)*2)+1+64)-(num1_int+32)]=SBUF;
if(((count-5)*2)%64==0)
{
num1_int=num1_int+32;
num_int=num_int+64;
}
}
RI=0;
xz_bit=1;
}
}
void display()
{
P0=255;//0xff
H2=H1=1;
H2=H1=0;
in_data();
rxd_data();
OUT_L=0;
OUT_L=1;
P0=ROW/256;
H2=1;
H2=0;
P0=ROW%256;
H1=1;
H1=0;
num++;
if(num==16)num=0;
ROW=_iror_(ROW,1);//左移
delay(150);
}
void rxd_data()
{ uchar l,i,temp;
if(time>=50)
{
time=0;
left++;
if(left>=8)
{left=0;
cc++;
if(cc>=2){cc=0;nib=nib+32;
if(nib>=count+32)nib=0;
}
}
}
for(l=0+cc;l<4+cc;l++)
{
temp=BUFF[l]<<left|BUFF[l+1]>>8-left;
for(i=0;i<8;i++)
{
temp<<=1;
DS_L=CY;
LATCH_L=0;
LATCH_L=1;
}
}
}
void in_data()
{
for(s=0;s<=2;s++)
{
BUFF[2*s+1]=TABLE[nib+s*32+1+2*num];
BUFF[2*s]=TABLE[nib+s*32+2*num];
}
}
void tim0() interrupt 1
{
TH0=0xfc;
TL0=0x18;
time++;
}
void tim1() interrupt 4
{
RXD_232();
}
嗯嗯,昨晚就试过这个,但是改过后字倒过来了,也就是说如果倒过来看确实是右移。。。。
一周热门 更多>