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

求助,液晶显示

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

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

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

×
我想显示 北京工商大学 信息工程学院 李浩 0804030106 帮我改改啊,谢谢

#include <reg51.h>
#define PD1 61 // 122/2 分成左右两半屏(122x32)
unsigned char Column;
unsigned char Page_ ; // 页地址寄存器 D1,DO:页地址
unsigned char Code_ ; // 字符代码寄存器
unsigned char Command; // 指令寄存器
unsigned char LCDData; // 数据寄存器
xdata unsigned char CWADD1 _at_ 0x8000; // 写指令代码地址(E1)
xdata unsigned char DWADD1 _at_ 0x8001; // 写显示数据地址(E1)
xdata unsigned char CRADD1 _at_ 0x8002; // 读状态字地址(E1)
xdata unsigned char DRADD1 _at_ 0x8003; // 读显示数据地址(E1)
xdata unsigned char CWADD2 _at_ 0x8004; // 写指令代码地址(E2)
xdata unsigned char DWADD2 _at_ 0x8005; // 写显示数进地址(E2)
xdata unsigned char CRADD2 _at_ 0x8006; // 读状态字地址(E2)
xdata unsigned char DRADD2 _at_ 0x8007; // 读显示数据地址(E2)
//英文字模库 8x8 点阵
code unsigned char EETAB[][8]={
{0x38,0x44,0x44,0x44,0x44,0x44,0x38,0x00}, // 0
{0x10,0x30,0x50,0x10,0x10,0x10,0x7c,0x00}, // 1
{0x38,0x44,0x04,0x08,0x10,0x20,0x7c,0x00}, // 2
{0x78,0x84,0x04,0x38,0x04,0x84,0x78,0x00}}; // 3
// 中文字模库 16x16点阵
code unsigned char CCTAB[][32] ={
{
0x00,0x20,0x20,0x20,0x20,0xFF,0x00,0x00,//北
0xFF,0x20,0x10,0x08,0x0C,0x00,0x00,0x00,
0x20,0x60,0x20,0x10,0x10,0x7F,0x00,0x00,
0x3F,0x40,0x40,0x40,0x40,0x40,0x70,0x00},
{0x08,0x08,0x08,0xE8,0x28,0x28,0x29,0x2E,//京
0x28,0x28,0x28,0xF8,0x28,0x0C,0x08,0x00,
0x00,0x00,0x40,0x23,0x1A,0x42,0x82,0x7E,
0x02,0x0A,0x12,0x33,0x60,0x00,0x00,0x00},
{0x00,0x04,0x04,0x04,0x04,0x04,0x04,0xFC,//工
0x04,0x04,0x04,0x04,0x06,0x04,0x00,0x00,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,
0x20,0x20,0x20,0x20,0x20,0x30,0x20,0x00},
{0x04,0x04,0xE4,0x24,0x2C,0xB4,0x25,0x26,//商
0x24,0xB4,0x2C,0x24,0xF4,0x26,0x04,0x00,
0x00,0x00,0xFF,0x02,0x01,0x3E,0x22,0x22,
0x22,0x3E,0x41,0x82,0x7F,0x00,0x00,0x00},
{0x20,0x20,0x20,0x20,0x20,0x20,0xA0,0x7F,//大
0xA0,0x20,0x20,0x20,0x20,0x30,0x20,0x00,
0x00,0x40,0x40,0x20,0x10,0x0C,0x03,0x00,
0x01,0x06,0x08,0x10,0x20,0x60,0x20,0x00},
{0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,//学
0x90,0x90,0x98,0x14,0x13,0x50,0x30,0x00,
0x04,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,
0x06,0x05,0x04,0x04,0x04,0x06,0x04,0x00}
" "

{0x80,0x40,0x20,0xF8,0x07,0x24,0x24,0x24,//信
0x25,0x26,0x24,0x24,0xB4,0x26,0x04,0x00,
0x00,0x00,0x00,0xFF,0x00,0x01,0xFD,0x45,
0x45,0x45,0x45,0x45,0xFD,0x01,0x00,0x00}
{0x00,0x00,0x00,0xFC,0xA4,0xA6,0xA5,0xA4,//息
0xA4,0xA4,0xA4,0xFE,0x04,0x00,0x00,0x00,
0x40,0x30,0x00,0x77,0x84,0x84,0x8C,0x94,
0xB4,0x84,0x84,0xE7,0x00,0x10,0x60,0x00}
{0x00,0x04,0x04,0x04,0x04,0x04,0x04,0xFC,//工
0x04,0x04,0x04,0x04,0x06,0x04,0x00,0x00,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,
0x20,0x20,0x20,0x20,0x20,0x30,0x20,0x00}
{0x24,0x24,0xA4,0xFE,0xA3,0x22,0x20,0x7E,//程
0x42,0x42,0x42,0x42,0x42,0x7F,0x02,0x00,
0x08,0x06,0x01,0xFF,0x00,0x43,0x41,0x49,
0x49,0x49,0x7F,0x49,0x4D,0x69,0x41,0x00}
{0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,//学
0x90,0x90,0x98,0x14,0x13,0x50,0x30,0x00,
0x04,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,
0x06,0x05,0x04,0x04,0x04,0x06,0x04,0x00}
{0x00,0xFE,0x22,0x5A,0x96,0x0C,0x24,0x24,//院
0x25,0x26,0x24,0x34,0xA4,0x14,0x0C,0x00,
0x00,0xFF,0x04,0x08,0x87,0x81,0x41,0x31,
0x0F,0x01,0x3F,0x41,0x41,0x41,0x70,0x00}
" "
{0x80,0x84,0x44,0x44,0x24,0x14,0x04,0xFF,//李
0x04,0x14,0x24,0x24,0x46,0xC4,0x40,0x00,
0x00,0x08,0x08,0x08,0x09,0x49,0x89,0x7D,
0x0D,0x0B,0x09,0x08,0x0C,0x08,0x00,0x00}
{0x10,0x21,0x62,0x06,0xA0,0x90,0x8E,0x88,//浩
0x88,0xFF,0x88,0x88,0x8C,0xC8,0x80,0x00,
0x04,0x04,0xFE,0x01,0x00,0x00,0xFE,0x42,
0x42,0x42,0x42,0x42,0xFF,0x02,0x00,0x00}

0x00,0x00,0xE0,0x0F,0x10,0x10,0x08,0x20,0x08,0x20,0x10,0x10,0xE0,0x0F,0x00,0x00,/*"0",0*/
0x00,0x00,0x10,0x20,0x10,0x20,0xF8,0x3F,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,/*"1",1*/
0x00,0x00,0x70,0x30,0x08,0x28,0x08,0x24,0x08,0x22,0x88,0x21,0x70,0x30,0x00,0x00,/*"2",2*/
0x00,0x00,0x30,0x18,0x08,0x20,0x88,0x20,0x88,0x20,0x48,0x11,0x30,0x0E,0x00,0x00,/*"3",3*/
0x00,0x00,0x00,0x07,0xC0,0x04,0x20,0x24,0x10,0x24,0xF8,0x3F,0x00,0x24,0x00,0x00,/*"4",4*/
0x00,0x00,0xF8,0x19,0x08,0x21,0x88,0x20,0x88,0x20,0x08,0x11,0x08,0x0E,0x00,0x00,/*"5",5*/
0x00,0x00,0xE0,0x0F,0x10,0x11,0x88,0x20,0x88,0x20,0x18,0x11,0x00,0x0E,0x00,0x00,/*"6",6*/
0x00,0x00,0x38,0x00,0x08,0x00,0x08,0x3F,0xC8,0x00,0x38,0x00,0x08,0x00,0x00,0x00,/*"7",7*/
0x00,0x00,0x70,0x1C,0x88,0x22,0x08,0x21,0x08,0x21,0x88,0x22,0x70,0x1C,0x00,0x00,/*"8",8*/
0x00,0x00,0xE0,0x00,0x10,0x31,0x08,0x22,0x08,0x22,0x10,0x11,0xE0,0x0F,0x00,0x00,/*"9",9*/
0x00,0x00,0x00,0x60,0x00,0x18,0x00,0x06,0x80,0x01,0x60,0x00,0x18,0x00,0x04,0x00/*"/",10*/
};

// 1.写指令代码子程序(E1)
void WriteCommandE1()
{
while(CRADD1 & 0x80);
CWADD1 = Command;
}
// 2.写显示数据子程序(E1)
void WriteDataE1()
{
while(CRADD1 & 0x80);
DWADD1 = LCDData;
}
// 3.读显示数据子程序(E1)
void ReadDataE1()
{
while(CRADD1 & 0x80);
LCDData = DRADD1;
}
// 4.写指令代码子程序(E2)
void WriteCommandE2()
{
while(CRADD2 & 0x80);
CWADD2 = Command;
}
// 5.写显示数据子程序(E2)
void WriteDataE2()
{
while(CRADD2 & 0x80);
DWADD2 = LCDData;
}
// 6.读显示数据子程序(E2)
void ReadDataE2()
{
while(CRADD2 & 0x80);
LCDData = DRADD2;
}
// 初始化程序
void Init()
{
Command = 0xe2;
WriteCommandE1();
WriteCommandE2();
Command = 0xa4;
WriteCommandE1();
WriteCommandE2();
Command = 0xa9;
WriteCommandE1();
WriteCommandE2();
Command = 0xa0;
WriteCommandE1();
WriteCommandE2();
Command = 0xc0;
WriteCommandE1();
WriteCommandE2();
Command = 0xaf;
WriteCommandE1();
WriteCommandE2();
}
// 清屏
void Clear()
{
unsigned char i,j;
i = 0;
do {
Command = (i + 0xb8); // 页地址设置
WriteCommandE1();
WriteCommandE2();
Command = 0x00; // 列地址设置为"0"
WriteCommandE1();
WriteCommandE2();
j = 0x50; // 一页清 80个字节
do {
LCDData = 0x00; // 显示数据为"0"
WriteDataE1();
WriteDataE2();
}while(--j !=0); // 页内字节清零循环
}while(++i !=4); // 页地址暂存器加一
// 显示区清零循环
}
// 延时程序
void Delay()
{
unsigned char i,j;
i = 20;
j = 0;
do{
do{
}while(--j !=0);
}while( --i != 0 );
}
// 中文显示子程序
void WriteCHN16x16()
{
unsigned char i,j,k;
i = 0;
j = 0;
while(j<2) {
Command = ((Page_ + j) & 0x03) | 0xb8; // 设置页地址
WriteCommandE1();
WriteCommandE2();
k = Column; // 列地址值
while(k < Column + 16){
if (k < PD1) { // 为左半屏显示区域(E1)
Command = k;
WriteCommandE1(); // 设置列地址值
LCDData = CCTAB[Code_][i]; // 取汉字字模数据
WriteDataE1(); // 写字模数据
} else{ // 为右半屏显示区域(E2)
Command = k-PD1;
WriteCommandE2(); // 设置列地址值
LCDData = CCTAB[Code_][i]; // 取汉字字模数据
WriteDataE2(); // 写字模数据
};
i++;
if( ++k >= PD1 * 2) break; // 列地址是否超出显示范围
} ;
j++;
};
}
// 中文显示程序
void main()
{
Init();
Clear();
Page_ = 0x02;
Column = 0x00;
Code_ = 0x00;
WriteCHN16x16();
Page_ = 0x02;
Column = 0x10;
Code_ = 0x01;
WriteCHN16x16();
Page_ = 0x02;
Column = 0x20;
Code_ = 0x02;
WriteCHN16x16();

Page_ = 0x02;
Column = 0x30;
Code_ = 0x03;
WriteCHN16x16();
Page_ = 0x02;
Column = 0x40;
Code_ = 0x04;
WriteCHN16x16();
Page_ = 0x02;
Column = 0x50;
Code_ = 0x05;
WriteCHN16x16();
while(1);
}
*滑块验证:
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

GMT+8, 2024-11-24 13:37 , Processed in 0.053315 second(s), 10 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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