| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4854 人关注过本帖
标题:让lcd1602显示一个字符‘A’,出现了问题
取消只看楼主 加入收藏
猴哥取经
Rank: 2
等 级:论坛游民
帖 子:41
专家分:34
注 册:2012-10-28
结帖率:50%
收藏
 问题点数:0 回复次数:0 
让lcd1602显示一个字符‘A’,出现了问题
#include<reg51.h>
#include<intrins.h>
#define uchar unsigned char
#define uint  unsigned int
sbit rs=P2^5;
sbit rw=P2^6;
sbit e=P2^7;
#define dataport P0
#define busy 0x80
uchar x;//行
uchar y;//列
void delay(uchar i)//延时一毫秒
{
  uchar j;
  for(;i>0;i--)
  for(j=0;j<125;j++);
}
void checkbusy()//检测是否处于忙状态
{
  dataport=0xff;
  rs=0;
  rw=1;
  _nop_();
  _nop_();
  e=1;
  _nop_();
  _nop_();
   _nop_();
  while(dataport&busy);//检测是否为忙状态
  e=0;
}
//写入IR命令函数 向lcd模块写入命令字符CMD
void writeIR(uchar cmd,uchar ac)
{
  if(ac) checkbusy();
  rs=0;
  rw=0;
  _nop_();
  _nop_();
  e=0;
  dataport=cmd;
  _nop_();
  _nop_();
  e=1;
  _nop_();
  _nop_();
  _nop_();
  e=0;
}
//以下是写入DDR寄存器函数
//功能:在当前光标位置显示一个字符
void writeDDR(uchar c)
{
  e=0;
  checkbusy();
  rs=1;
  rw=0;
  _nop_();
  dataport=c;
  _nop_();
  e=1;
  _nop_();
  _nop_();
  e=0;
}
//以下是光标定位函数
void lcdpoit(uchar x,uchar y)
{
   uchar temp;
   x&=0x01;
   y&=0x0f;
   temp=y;
   if(x==0)
   temp+=0x80;
   temp+=0xc0;
   
   writeIR(temp,0);
}
//初始化函数,向lcd写入不同的命令,完成必要的初始化过程
void lcdset()
{
  writeIR(0x38,0);
  _nop_();
  writeIR(0x38,1);
  _nop_();
  writeIR(0x08,1);
  _nop_();
  writeIR(0x01,1);
  _nop_();
  writeIR(0x06,1);
  _nop_();
  writeIR(0x0f,1);
  _nop_();

}
//以下是制定行列的显示
void writechar(uchar x,uchar y,char c)
{
lcdpoit(x,y);
writeDDR(c);

}     

void main(void)
{
 lcdset();
 delay (5);
 writechar(1,0,'A');
 while(1);
}



为什么没有显示呀???求大神指教!!!!!!!!!!!!!!!不甚感激!!!!!!!!!!!!!!!
搜索更多相关主题的帖子: include 检测 
2013-06-18 13:18
快速回复:让lcd1602显示一个字符‘A’,出现了问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028350 second(s), 8 queries.
Copyright©2004-2025, BC-CN.NET, All Rights Reserved