已经解决,谢谢大家的支持!
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit rs=P3^5;
sbit e=P3^4;
sbit rw=P3^6;
sbit rest=P3^1;
sbit csa=P3^2;
sbit csb=P3^3;
sbit dula=P2^6;
sbit wela=P2^7;
uchar num;
void delay(uint z)
{
uchar x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void write_com(uchar com)//写命令
{
rs=0;
rw=0;
P0=com;
e=1;
delay(5);
e=0;
}
void red_com(uchar com)
{
rs=0;
rw=1;
e=1;
delay(5);
P0=com;
}
void write_date(uchar date)//写数据
{
rs=1;
rw=0;
P0=date;
e=1;
delay(5);
e=0;
}
void red_date(uchar date)
{
rs=1;
rw=1;
e=1;
delay(5);
P0=date;
}
uchar code table[]={
//"我",
0x20,0x24,0x24,0x24,0xFE,0x23,0x22,0x20,
0xFF,0x20,0x22,0xAC,0x20,0x30,0x20,0x00,
0x00,0x08,0x48,0x84,0x7F,0x02,0x21,0x10,
0x09,0x06,0x1A,0x61,0x80,0xE0,0x00,0x00,
//"自",
0x00,0x00,0x00,0xF8,0x48,0x4C,0x4A,0x49,
0x48,0x48,0x48,0xFC,0x08,0x00,0x00,0x00,
0x00,0x00,0x00,0xFF,0x44,0x44,0x44,0x44,
0x44,0x44,0x44,0xFF,0x00,0x00,0x00,0x00,
//"己",
0x00,0x04,0x84,0x84,0x84,0x84,0x84,0x84,
0x84,0x84,0x84,0xFE,0x04,0x00,0x00,0x00,
0x00,0x00,0x3F,0x40,0x40,0x40,0x40,0x40,
0x40,0x40,0x40,0x41,0x40,0x70,0x00,0x00,
//"写",
0x08,0x06,0x02,0x02,0xFA,0x22,0x22,0x22,
0x22,0x22,0x32,0x22,0x82,0x0A,0x06,0x00,
0x00,0x08,0x08,0x08,0x09,0x09,0x09,0x09,
0x09,0x4D,0x89,0x41,0x3F,0x01,0x00,0x00
};
void init()
{
csa=1;
csb=1;
rest=1;
dula=0;
wela=0;
write_com(0x3f);//开显示
write_com(0x3e );//关显示
write_com(0xc0);//显示起始行设置
write_com(0xb8);//页面地址设置
write_com(0x40);//列地址设置
red_com(0x10);//读状态字
delay(5);
// red_date(table[num]);//读数据
}
/*--------------写点阵------------------*/
void lat_disp (uchar data1,uchar data2)
{
uchar i,j;
csa=1;csb=1;
write_com(0x3f);
for(j=0;j<8;j++)
{
write_com (0xb8+j);//0xb8+j
write_com (0xc0);//0xc0
write_com (0x40);//0x40
for(i=0;i<32;i++)
{
write_date(data1);
write_date(data2);
}
}
}
/*---指定位置(x,y)显示row_xl行(每行row_yl个)汉字(大小8xl*yl)---*/
void chn_disp (uchar x,uchar y,uchar xl,uchar yl,uchar
row_xl,uchar row_yl,uchar code *chn)
{
uchar i,j,k,l,a;
write_com(0x3f);
for(l=0;l<row_xl;l++)
{
for(k=0;k<row_yl;k++)
{
for(j=0;j<xl;j++)
{
write_com(0xb8+x+l*xl+j);
write_com(0xc0);
write_com(0x40+y+k*yl);
a=l*xl*yl*row_yl+k*xl*yl+j*yl;
for(i=0;i<yl;i++)
write_date (chn[a+i]);
}
}
}
}
void disply()
{
lat_disp(0x00,0x00);
delay(100);
csa=1;csb=0;
chn_disp (3,0,2,16,1,4,table);
delay(100);
}
void main()
{
init();
disply();
while(1);
} |