我知道 附上程序,很少人 会看,但是小弟为此真的 看了2天了 还是毫无进展,才在这里咨询大家, 希望赏脸看下, 其实也就是 读写模块, 还有这个程序比较清晰,我一直在PROTUES里用它去进行修改
#include<reg52.h>
#define uchar unsigned char
#define lcd P0
sbit cs1 = P2^1; //换位了cs1和cs2
sbit cs2 = P2^2;
sbit rw = P2^5;
sbit rs = P2^4;
sbit e= P2^6;
sbit busy=ACC^7; //按列取,且字符是倒着的,第二排是第一排的,
uchar code wo[32]={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
};
uchar code xiang[32]={0x08,0x88,0x68,0xFF,0x48,0x88,0x08,0xFE,0x52,0x52,0x52,0x52,0xFF,0x02,0x00,0x00,
0x41,0x30,0x00,0x7B,0x80,0x80,0x88,0x93,0xB2,0x82,0x82,0xE2,0x03,0x10,0x60,0x00
};
uchar code ni[32]={0x40,0x20,0xF8,0x07,0x40,0x20,0x18,0x0F,0x08,0xC8,0x08,0x08,0x28,0x18,0x00,0x00,
0x00,0x00,0xFF,0x00,0x00,0x08,0x04,0x43,0x80,0x7F,0x00,0x01,0x06,0x0C,0x00,0x00
};
uchar code le[32]={0x00,0x02,0x02,0x02,0x02,0x02,0x02,0xE2,0x22,0x12,0x0A,0x06,0x02,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
void lcd_mwcode(uchar i) //输入控制字,
{
rw=1;
rs=0;
lcd=0;
e=1;
do{ACC=lcd; //是否忙
e=0; }
while(busy);
rw=0;
lcd=i;
e=1;
e=0;
}
void lcd_mwdata(uchar i) //输入数据,
{
rw=1;
rs=0;
lcd=0;
e=1;
do{ACC=lcd;
e=0;}
while(busy);
rw=0;
rs=1;
lcd=i;
e=1;
e=0;}
void setpos(uchar row , uchar col) //选择行,列,
{
lcd_mwcode(0xb8+row);
lcd_mwcode(0x40+col);
}
void lcd_init(void) //初始化
{
lcd_mwcode(0xc0);
lcd_mwcode(0x3f);
}
void disp1(uchar code *hz) //显示汉字上半区,
{
uchar i;
for(i=0;i<16;i++)
lcd_mwdata(*(hz+i));
}
void disp2(uchar code *hz) //显示汉字下半区 ,
{
uchar i;
for(i=16;i<32;i++)
lcd_mwdata(*(hz+i));
}
void select(uchar x)
{ switch(x)
{ case 1:cs1=0;cs2=1;break; //左屏,
case 2:cs1=1;cs2=0;break; //右屏,
default :cs2=0;cs2=0;}
}
void main()
{
lcd_init(); //初始化
select(1); //选择左屏
setpos(0,16);
disp1(&wo);
disp1(&xiang);
setpos(1,16); //下一页
disp2(&wo);
disp2(&xiang);
select(2); //选择右屏
setpos(2,5);
disp1(&ni);
disp1(&le);
setpos(3,5); //下一页
disp2(&ni);
disp2(&le);
} |