单片机使用LCD12864为什么只亮不显示啊
我已经用杜邦线按照端口的定义去连接了,可还是不行啊,请问各位大神问题出在哪里啊?程序如下,只显示几条线条啊!!!急死了,几天都没解决,换了好多程序了都是一样的结果啊#in...
我已经用杜邦线按照端口的定义去连接了,可还是不行啊,请问各位大神问题出在哪里啊?程序如下,只显示几条线条啊!!!急死了,几天都没解决,换了好多程序了都是一样的结果啊
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
/*12864端口定义*/
#define LCD_data P0 //数据口
sbit LCD_RS = P1^0; //寄存器选择输入
sbit LCD_RW = P1^1; //液晶读/写控制
sbit LCD_EN = P2^5; //液晶使能控制
sbit LCD_PSB = P1^2; //串/并方式控制
sbit wela = P2^6;
sbit dula = P2^7;
uchar code dis1[] = {"慧净电子"};
uchar code dis2[] = {"www.hjmcu.com"};
uchar code dis3[] = {"HL-1 学习板 "};
uchar code dis4[] = {"是您最好的选择! "};
#define delayNOP(); {_nop_();_nop_();_nop_();_nop_();};
uchar IRDIS[2];
uchar IRCOM[4];
void delay0(uchar x);
void beep();
void dataconv();
void lcd_pos(uchar X,uchar Y);
void delay(int ms)
{
while(ms--)
{
uchar i;
for(i=0;i<250;i++)
{
_nop_();
_nop_();
_nop_();
_nop_();
}
}
}
bit lcd_busy()
{
bit result;
LCD_RS = 0;
LCD_RW = 1;
LCD_EN = 1;
delayNOP();
result = (bit)(P0&0x80);
LCD_EN = 0;
return(result);
}
void lcd_wcmd(uchar cmd)
{
while(lcd_busy());
LCD_RS = 0;
LCD_RW = 0;
LCD_EN = 0;
_nop_();
_nop_();
P0 = cmd;
delayNOP();
LCD_EN = 1;
delayNOP();
LCD_EN = 0;
}
void lcd_wdat(uchar dat)
{
while(lcd_busy());
LCD_RS = 1;
LCD_RW = 0;
LCD_EN = 0;
P0 = dat;
delayNOP();
LCD_EN = 1;
delayNOP();
LCD_EN = 0;
}
void lcd_init()
{
LCD_PSB = 1;
lcd_wcmd(0x34);
delay(5);
lcd_wcmd(0x30);
delay(5);
lcd_wcmd(0x0C);
delay(5);
lcd_wcmd(0x01);
delay(5);
}
main()
{
uchar i;
delay(10);
wela=0;
dula=0;
lcd_init();
lcd_pos(0,0);
i = 0;
while(dis1[i] != '\0')
{
lcd_wdat(dis1[i]);
i++;
}
lcd_pos(1,0);
i = 0;
while(dis2[i] != '\0')
{
lcd_wdat(dis2[i]);
i++;
}
lcd_pos(2,0);
i = 0;
while(dis3[i] != '\0')
{
lcd_wdat(dis3[i]);
i++;
}
lcd_pos(3,0);
i = 0;
while(dis4[i] != '\0')
{
lcd_wdat(dis4[i]);
i++;
}
while(1);
}
void delay0(uchar x)
{
uchar i;
while(x--)
{
for (i = 0; i<13; i++) {}
}
}
void lcd_pos(uchar X,uchar Y)
{
uchar pos;
if (X==0)
{X=0x80;}
else if (X==1)
{X=0x90;}
else if (X==2)
{X=0x88;}
else if (X==3)
{X=0x98;}
pos = X+Y ;
lcd_wcmd(pos);
} 展开
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
/*12864端口定义*/
#define LCD_data P0 //数据口
sbit LCD_RS = P1^0; //寄存器选择输入
sbit LCD_RW = P1^1; //液晶读/写控制
sbit LCD_EN = P2^5; //液晶使能控制
sbit LCD_PSB = P1^2; //串/并方式控制
sbit wela = P2^6;
sbit dula = P2^7;
uchar code dis1[] = {"慧净电子"};
uchar code dis2[] = {"www.hjmcu.com"};
uchar code dis3[] = {"HL-1 学习板 "};
uchar code dis4[] = {"是您最好的选择! "};
#define delayNOP(); {_nop_();_nop_();_nop_();_nop_();};
uchar IRDIS[2];
uchar IRCOM[4];
void delay0(uchar x);
void beep();
void dataconv();
void lcd_pos(uchar X,uchar Y);
void delay(int ms)
{
while(ms--)
{
uchar i;
for(i=0;i<250;i++)
{
_nop_();
_nop_();
_nop_();
_nop_();
}
}
}
bit lcd_busy()
{
bit result;
LCD_RS = 0;
LCD_RW = 1;
LCD_EN = 1;
delayNOP();
result = (bit)(P0&0x80);
LCD_EN = 0;
return(result);
}
void lcd_wcmd(uchar cmd)
{
while(lcd_busy());
LCD_RS = 0;
LCD_RW = 0;
LCD_EN = 0;
_nop_();
_nop_();
P0 = cmd;
delayNOP();
LCD_EN = 1;
delayNOP();
LCD_EN = 0;
}
void lcd_wdat(uchar dat)
{
while(lcd_busy());
LCD_RS = 1;
LCD_RW = 0;
LCD_EN = 0;
P0 = dat;
delayNOP();
LCD_EN = 1;
delayNOP();
LCD_EN = 0;
}
void lcd_init()
{
LCD_PSB = 1;
lcd_wcmd(0x34);
delay(5);
lcd_wcmd(0x30);
delay(5);
lcd_wcmd(0x0C);
delay(5);
lcd_wcmd(0x01);
delay(5);
}
main()
{
uchar i;
delay(10);
wela=0;
dula=0;
lcd_init();
lcd_pos(0,0);
i = 0;
while(dis1[i] != '\0')
{
lcd_wdat(dis1[i]);
i++;
}
lcd_pos(1,0);
i = 0;
while(dis2[i] != '\0')
{
lcd_wdat(dis2[i]);
i++;
}
lcd_pos(2,0);
i = 0;
while(dis3[i] != '\0')
{
lcd_wdat(dis3[i]);
i++;
}
lcd_pos(3,0);
i = 0;
while(dis4[i] != '\0')
{
lcd_wdat(dis4[i]);
i++;
}
while(1);
}
void delay0(uchar x)
{
uchar i;
while(x--)
{
for (i = 0; i<13; i++) {}
}
}
void lcd_pos(uchar X,uchar Y)
{
uchar pos;
if (X==0)
{X=0x80;}
else if (X==1)
{X=0x90;}
else if (X==2)
{X=0x88;}
else if (X==3)
{X=0x98;}
pos = X+Y ;
lcd_wcmd(pos);
} 展开
3个回答
2015-04-10
展开全部
http://www.openedv.com/posts/list/11568.htm
去看看我以前写的一个程序,里面有LCD12864 的程序
去看看我以前写的一个程序,里面有LCD12864 的程序
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你好,我也遇到了同样的问题,请问解决了吗?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
需要给你完成一份吗
追问
可以啊,但是貌似怎么都不显示啊,我是端口没对吗
追答
代做的
我id
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询