LCD12864显示程序,我用89c52的,用综合网上搜索整理以下程序,可是显示不出来,请高手指点问题出在哪呢
LCD12864显示程序,我用89c52的,用串行连接,谁可以给我个能显示汉字的程序,不胜感激啊,我邮箱justin_jia1983@hotmail.com我调了2天都没...
LCD12864显示程序,我用89c52的,用串行连接,谁可以给我个能显示汉字的程序,不胜感激啊,我邮箱justin_jia1983@hotmail.com 我调了2天都没调出来。
展开
3个回答
展开全部
#include <regx52.h>
#include <intrins.h>
#include <string.h>
#define uchar unsigned char //自定义关键字
#define BUSY_FLAG P0_7 //液晶模块忙标志
#define MPU_RS_CH P2_7 //寄存器选择输入 RS
#define MPU_RW_CH P2_6 //读写控制 RW
#define MPU_ENABLE P2_5 //使能控制 E
#define MPU_PS_CH P3_6 //串/并传输控制 PSB
#define MPU_RESET P3_7 //液晶复位控制 RST
#define LCD_DATA P0 //液晶数据口 P0
#define LOW 0 //低电平
#define HIGH 1 //高电平
#define OFF 0 //逻辑关
#define ON 1 //逻辑开
//-----------------------------------------------
//液晶模块指令集定义
#define cClearDisplay 0x01 //清显示指令
#define cEntryModeSet 0x06 //设置输入模式
#define cDisplayOnCtrl 0x0c //设置开显控制
#define cFunctionSetB 0x30 //功能设定(基本指令)
#define cFunctionSetE 0x34 //功能设定(扩充指令)
//-----------------------------------------------
void checkLcdBusy (void)
{
LCD_DATA = 0xff;
MPU_RS_CH = LOW;
MPU_RW_CH = HIGH;
MPU_ENABLE = HIGH;
while (BUSY_FLAG);
MPU_ENABLE = LOW;
}
//===============================================
void delayMs (uchar ms)
{
uchar i;
while (--ms)
for (i = 0; i < 125; i++);
}
//===============================================
void delaySec (uchar sec)
{
uchar i;
while (--sec)
for (i = 0; i < 200; i++)
delayMs (6);
}
//===============================================
void lcdWriteCommand (uchar Command)
{
checkLcdBusy();
MPU_RS_CH = LOW;
MPU_RW_CH = LOW;
LCD_DATA = Command;
MPU_ENABLE = HIGH;
delayMs(1);
MPU_ENABLE = LOW;
}
//===============================================
void lcdClear (void)
{
lcdWriteCommand(cClearDisplay);
}
//===============================================
void lcdInit (void) //初始化LCD子程序
{
MPU_RESET = LOW;
delayMs(40);
MPU_RESET = HIGH;
delayMs(1);
MPU_PS_CH = HIGH;
lcdWriteCommand(cFunctionSetE);
lcdWriteCommand(cFunctionSetB);
lcdWriteCommand(cEntryModeSet);
lcdWriteCommand(cDisplayOnCtrl);
}
//===============================================
void lcdWriteData (uchar Data)
{
checkLcdBusy();
MPU_RS_CH = HIGH;
MPU_RW_CH = LOW;
LCD_DATA = Data;
MPU_ENABLE = HIGH;
delayMs(1);
MPU_ENABLE = LOW;
}
//===============================================
void dispString (uchar X, Y, speed, uchar *msg)
{
if (X == 0) X = 0x80;
else if (X == 1) X = 0x90;
else if (X == 2) X = 0x88;
else if (X == 3) X = 0x98;
Y = X + Y;
lcdWriteCommand(Y);
while (*msg)
{
lcdWriteData(*msg++);
delayMs(speed);
}
}
//===============================================
void main (void)
{
lcdInit ();
lcdClear();
while(1)
{
dispString(0, 1, 0, "university"); delaySec(1);
dispString(1, 1, 0, "新区"); delaySec(1);
dispString(2, 1, 0, "电气学院"); delaySec(1);
dispString(3, 1, 0, "班级:083"); delaySec(6);
lcdClear();
dispString(0, 2, 0, "单片机开发"); delaySec(1);
dispString(1, 0, 0, "电子设备研究开发"); delaySec(1);
dispString(2, 2, 0, "毕业设计"); delaySec(1);
dispString(3, 1, 0, "学生智能宿舍"); delaySec(6);
lcdClear();
dispString(0, 0, 0, "联系人:喜哥"); delaySec(1);
dispString(1, 0, 0, "电话:007"); delaySec(1);
dispString(2, 0, 0, "手机:008"); delaySec(1);
dispString(3, 0, 0, "共同学习共同进步"); delaySec(6);
lcdClear();
}
}
#include <intrins.h>
#include <string.h>
#define uchar unsigned char //自定义关键字
#define BUSY_FLAG P0_7 //液晶模块忙标志
#define MPU_RS_CH P2_7 //寄存器选择输入 RS
#define MPU_RW_CH P2_6 //读写控制 RW
#define MPU_ENABLE P2_5 //使能控制 E
#define MPU_PS_CH P3_6 //串/并传输控制 PSB
#define MPU_RESET P3_7 //液晶复位控制 RST
#define LCD_DATA P0 //液晶数据口 P0
#define LOW 0 //低电平
#define HIGH 1 //高电平
#define OFF 0 //逻辑关
#define ON 1 //逻辑开
//-----------------------------------------------
//液晶模块指令集定义
#define cClearDisplay 0x01 //清显示指令
#define cEntryModeSet 0x06 //设置输入模式
#define cDisplayOnCtrl 0x0c //设置开显控制
#define cFunctionSetB 0x30 //功能设定(基本指令)
#define cFunctionSetE 0x34 //功能设定(扩充指令)
//-----------------------------------------------
void checkLcdBusy (void)
{
LCD_DATA = 0xff;
MPU_RS_CH = LOW;
MPU_RW_CH = HIGH;
MPU_ENABLE = HIGH;
while (BUSY_FLAG);
MPU_ENABLE = LOW;
}
//===============================================
void delayMs (uchar ms)
{
uchar i;
while (--ms)
for (i = 0; i < 125; i++);
}
//===============================================
void delaySec (uchar sec)
{
uchar i;
while (--sec)
for (i = 0; i < 200; i++)
delayMs (6);
}
//===============================================
void lcdWriteCommand (uchar Command)
{
checkLcdBusy();
MPU_RS_CH = LOW;
MPU_RW_CH = LOW;
LCD_DATA = Command;
MPU_ENABLE = HIGH;
delayMs(1);
MPU_ENABLE = LOW;
}
//===============================================
void lcdClear (void)
{
lcdWriteCommand(cClearDisplay);
}
//===============================================
void lcdInit (void) //初始化LCD子程序
{
MPU_RESET = LOW;
delayMs(40);
MPU_RESET = HIGH;
delayMs(1);
MPU_PS_CH = HIGH;
lcdWriteCommand(cFunctionSetE);
lcdWriteCommand(cFunctionSetB);
lcdWriteCommand(cEntryModeSet);
lcdWriteCommand(cDisplayOnCtrl);
}
//===============================================
void lcdWriteData (uchar Data)
{
checkLcdBusy();
MPU_RS_CH = HIGH;
MPU_RW_CH = LOW;
LCD_DATA = Data;
MPU_ENABLE = HIGH;
delayMs(1);
MPU_ENABLE = LOW;
}
//===============================================
void dispString (uchar X, Y, speed, uchar *msg)
{
if (X == 0) X = 0x80;
else if (X == 1) X = 0x90;
else if (X == 2) X = 0x88;
else if (X == 3) X = 0x98;
Y = X + Y;
lcdWriteCommand(Y);
while (*msg)
{
lcdWriteData(*msg++);
delayMs(speed);
}
}
//===============================================
void main (void)
{
lcdInit ();
lcdClear();
while(1)
{
dispString(0, 1, 0, "university"); delaySec(1);
dispString(1, 1, 0, "新区"); delaySec(1);
dispString(2, 1, 0, "电气学院"); delaySec(1);
dispString(3, 1, 0, "班级:083"); delaySec(6);
lcdClear();
dispString(0, 2, 0, "单片机开发"); delaySec(1);
dispString(1, 0, 0, "电子设备研究开发"); delaySec(1);
dispString(2, 2, 0, "毕业设计"); delaySec(1);
dispString(3, 1, 0, "学生智能宿舍"); delaySec(6);
lcdClear();
dispString(0, 0, 0, "联系人:喜哥"); delaySec(1);
dispString(1, 0, 0, "电话:007"); delaySec(1);
dispString(2, 0, 0, "手机:008"); delaySec(1);
dispString(3, 0, 0, "共同学习共同进步"); delaySec(6);
lcdClear();
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
现在市场上的12864一般都有带中文字库的,比如你要显示汉字“国”,你直接就可以把汉字作为字符串显示就行了,
如果你的液晶没有中文字库的话就需要一个字模软件,获取汉字的点阵,就以图片的方式显示出来,这样也可以显示出汉字;
欢迎追问
如果你的液晶没有中文字库的话就需要一个字模软件,获取汉字的点阵,就以图片的方式显示出来,这样也可以显示出汉字;
欢迎追问
追问
我现在已经调出英文了,但是中文不会显示,是乱码,显示屏是支持中文字库的,请问程序问题可能出在哪里呢
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
广播
转发`3~我想你,想在2010放下你`3~嘿嘿,这哪跟哪啊!`3~今天是周一,哈`3~英超还是很八错
转发`3~我想你,想在2010放下你`3~嘿嘿,这哪跟哪啊!`3~今天是周一,哈`3~英超还是很八错
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询