找回密码
 注册会员
更新自动建库工具PCB Footprint Expert 2024.04 Pro / Library Expert 破解版

lcd无法显示字符

[复制链接]
admin 发表于 2012-9-2 08:27:45 | 显示全部楼层 |阅读模式

本文包含原理图、PCB、源代码、封装库、中英文PDF等资源

您需要 登录 才可以下载或查看,没有账号?注册会员

×
请各位帮忙看看有什么问题,先谢谢了
lcd有反应但是就是无法显示字符
源程序:
#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
#define NOP _nop_( )
sbit RS=P2^5;
sbit RW=P2^6;
sbit E=P2^7;
void delay(int ms) //延时程序
{
int i;
while(ms--)
{
for(i = 0; i< 250; i++)
{
_nop_();
_nop_();
_nop_();
_nop_();
}
}
}
uchar read_busy( )//读忙标志位
{
uchar chr,temp=0;
P0=0x00;
RS=0;
RW=1;
E=0;
NOP;
NOP;
E=1;
chr=P0;
while(chr&&0x80)
{temp=1;}
return temp;
}
void write_cmd(uchar a)//写指令
{
while(read_busy( ));
RS=0;
RW=0;
E=0;
NOP;
NOP;
E=1;
P0=a;
NOP;
NOP;
NOP;
E=0;
NOP;
NOP;
RS=1;
RW=1;
}
void write_data(uchar temp) //写数据
{
while(read_busy( ));
RS=1;
RW=0;
E=0;
NOP;
NOP;
E=1;
P0=temp;
NOP;
NOP;
E=0;
NOP;
NOP;
RS=0;
RW=1;
}
void unitlcd( ) //程序初始化
{
delay(15);
write_cmd(0x38);
delay(5);
write_cmd(0x38);
delay(5);
write_cmd(0x38);
delay(5);
while(read_busy( ));
write_cmd(0x38);
delay(5);
while(read_busy( ));
write_cmd(0x06);
//while(read_busy( ));
//write_cmd(0x14);
delay(5);
while(read_busy( ));
write_cmd(0x0e);
delay(5);
while(read_busy( ));
write_cmd(0x01);
}
uchar address(uchar tap)//取地址值
{
return(tap|0x80);
}
void display(uchar temp1,uchar temp2)//写入地址和数据
{
while(read_busy( ));
write_cmd(address(temp1));
delay(15);
while(read_busy( ));
write_data(temp2);
}
void main( )
{
unitlcd( );
while(1)
{
display(0x01,'a');
display(0x41,1);
}
}


proteus仿真原理图



17 分钟前 上传
下载附件 (11.51 KB)




5_158958_b6c86eb1a56e15b.png
*滑块验证:
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

QQ|手机版|MCU资讯论坛 ( 京ICP备18035221号-2 )|网站地图

GMT+8, 2024-11-24 10:01 , Processed in 0.053604 second(s), 12 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表