文号
t79942
阅读
14722
回复
14
收藏
9
这个LCD1602程序怎么回事,怎么没有显示?
2016/05/14
IP:江苏
IMG_20160514_210244.jpg

#include <reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
unsigned char code word1[]={"FUCK YOU"};//单字符用单引号双字符用双引号
unsigned char code word2[]={"Asshole"};
sbit RS = P1^0 ;
sbit RW = P1^1 ;
sbit EN = P2^5 ;
sbit STA7 = P0^7;
void wait()
{
P0 = 0xFF;

do
{
RS = 0;
RW = 1;
EN = 0;
EN = 1;
}while (STA7 == 1);
EN = 0;
}


void w_dat(uint dat)
{
wait();
EN = 0;
P0 = dat;
RS = 1;
RW = 0;
EN = 1;
EN = 0;
}
void w_cmd(uint cmd)
{
wait();
EN = 0;
P0 = cmd;
RS = 0;
RW = 0;
EN = 1;
EN = 0;
}
void w_string(uint addr_start,uint *p)
{
w_cmd(addr_start);
while (*p != '\0')
{
w_dat(*p++);
}
}
void Init_LCD1602()
{
w_cmd(0x38);  // 16*2显示,5*7点阵,8位数据接口
w_cmd(0x0C);  // 显示器开、光标开、光标允许闪烁
w_cmd(0x06);  // 文字不动,光标自动右移
w_cmd(0x01);  // 清屏
}




main()
{
    Init_LCD1602();
    w_string(0x80,word1);
w_string(0xC0,word2);
while (1);
}
10年7个月前IP:浙江
819276
1楼
对比度先调好,现在根本不知道显示什么
引用
评论
10年7个月前IP:江苏
819289
2楼
我拿商家的程序试过显示了,但我自己写的不行
引用
评论
10年7个月前修改于 10年7个月前IP:山东
819349
3楼
引用 懒惰的0族元素:
我拿商家的程序试过显示了,但我自己写的不行
写入速度太高?,不检测第8位电平,直接加个延时试试
引用
评论
10年7个月前IP:北京
819411
4楼
不文明用语自动屏蔽
引用
评论
10年7个月前IP:广东
819428
5楼
这样写当然不行
引用
评论
10年7个月前IP:广东
819442
6楼
初始化失败通常是因为代码有错误,没有生成应生成的信号。
引用
评论
10年7个月前IP:江苏
819510
7楼
引用 电子黑马:
这样写当然不行
具体怎么改
引用
评论
10年7个月前IP:江苏
819511
8楼
引用 novakon:
初始化失败通常是因为代码有错误,没有生成应生成的信号。
具体怎么改?
引用
评论
10年7个月前IP:澳大利亚
819636
9楼
几点建议
E的高电平保持时间长一些
单片机上电之后等一下再开始初始化
检测lcd忙的换成比较长的延时
引用
评论
10年7个月前IP:天津
819637
10楼
为什么我感觉是对比度没调好?
引用
评论
10年7个月前IP:浙江
819638
11楼
你这个是v0直接接电源了?你上下你现在的接线图看看
引用
评论
10年6个月前IP:江苏
820273
12楼
改过了,然而还是没有什么变化
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[]="FUCK YOU";
uchar code table1[]="Asshole";
sbit BF=P0^7;
sbit EN=P2^5;
sbit RS=P1^0;
sbit dula=P2^6;
sbit wela=P2^7;
uchar num;
void delay(uint z)
{
  uint x,y;
  for(x=z;x>0;x--)
   for(y=110;y>0;y--);
  }
void w_cmd(uchar cmd)
{
RS=0;
P0=cmd;
delay(5);
EN=1;
delay(5);
EN=0;
}
  void w_dat(uchar dat)
  {
RS = 1;
P0 = dat;
   delay(5);
EN = 1;
delay(5);
EN = 0;
  }
void Init_LCD1602()
  {
    dula=0;
wela=0;
EN=0;
    w_cmd(0x38);  // 16*2显示,5*7点阵,8位数据接口
w_cmd(0x0C);  // 显示器开、光标开、光标允许闪烁
w_cmd(0x06);  // 文字不动,光标自动右移
w_cmd(0x01);  // 清屏
  }
void main()
{
Init_LCD1602();
w_cmd(0x80);//选择显示位置此时为0位80每加1就移一位
for(num=0;num<11;num++)
{
   w_dat(table[num]);
   delay(5);
}
w_cmd(0x80+0x40);
{
w_dat(table1[num]);
delay(5);
}
while(1);
}
引用
评论
10年6个月前IP:澳大利亚
820350
13楼
main开始之后加以点延时再初始化
引用
评论
笔记
{{note.content}}
{{n.user.username}}
{{fromNow(n.toc)}} {{n.status === noteStatus.disabled ? "已屏蔽" : ""}} {{n.status === noteStatus.unknown ? "正在审核" : ""}} {{n.status === noteStatus.deleted ? '已删除' : ''}}
  • 编辑
  • 删除
  • {{n.status === 'disabled' ? "解除屏蔽" : "屏蔽" }}
我也是有底线的