菜鸟学习51单片机之12864液晶(无字库)
51单片机驱动显示屏12864
/*-- 文字: 机 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x10,0xD0,0xFF,0x90,0x10,0x00,0xFE,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,
0x04,0x03,0x00,0xFF,0x00,0x11,0x08,0x04,0x03,0x00,0xFF,0x00,0x03,0x04,0x08,0x00,
/*-- 文字: 辉 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x44,0x58,0xC0,0x7F,0xD0,0x48,0x26,0x22,0xE2,0x3A,0xA2,0x22,0x22,0x2A,0x06,0x00,
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,
/*-- 文字: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
uchar code hz[]={
/*-- 文字: 邓 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x12,0x22,0x42,0x82,0x62,0x1E,0x00,0x00,0xFE,0x02,0x22,0xDA,0x06,0x00,0x00,
51单片机经典C程序(12864)
/*************************************** 控制器:KS0108* MCU:AT89C5* ,晶体频率:12MHz* 取模方式:纵向字节倒序* CS1和CS2为低电平有效**************************************/#include <reg52.h>#define uchar unsigned char#define uint unsigned int#define LCD_PORT P0#define Left 1#define Right 2sbit LCD_Busy=P0^7;sbit LCD_EN = P1^2;sbit LCD_RS = P1^0;sbit LCD_RW = P1^1;sbit LCD_RST= P1^7;sbit LCD_CS2= P3^6;sbit LCD_CS1= P3^5;uchar DisBuf[32],Page_Num,Clm_Num;code char Table0[]={/*-- 文字: A --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27 ,0x38,0x20,/*-- 文字: B --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11 ,0x0E,0x00,/*-- 文字: C --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10 ,0x08,0x00,/*-- 文字: D --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10 ,0x0F,0x00,/*-- 文字: E --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20 ,0x18,0x00,/*-- 文字: F --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00 ,0x00,0x00,/*-- 文字: G --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E ,0x02,0x00,};code unsigned char Table3[]={/*-- 文字: 天 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x40,0x42,0x42,0x42,0x42,0x42,0xFE,0x42,0x42,0x42,0x42,0x42,0x42 ,0x40,0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x06,0x01,0x02,0x04,0x08,0x10,0x30,0x60 ,0x20,0x00,/*-- 文字: 仙 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x80,0x60,0xF8,0x07,0x02,0xE0,0x00,0x00,0x00,0xFF,0x00,0x00,0x00 ,0xE0,0x00,0x01,0x00,0x00,0x7F,0x00,0x20,0x7F,0x20,0x20,0x20,0x3F,0x20,0x20,0x20 ,0x7F,0x00,/*-- 文字: 妹 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x08,0x88,0x7F,0x0A,0x08,0xF8,0x80,0x88,0x88,0x88,0xFF,0x88,0x88,0x88 ,0x80,0x00,0x40,0x21,0x12,0x0C,0x3A,0x11,0x40,0x30,0x0C,0x03,0xFF,0x06,0x08,0x30 ,0x10,0x00,/*-- 文字: 妹 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x08,0x88,0x7F,0x0A,0x08,0xF8,0x80,0x88,0x88,0x88,0xFF,0x88,0x88,0x88 ,0x80,0x00,0x40,0x21,0x12,0x0C,0x3A,0x11,0x40,0x30,0x0C,0x03,0xFF,0x06,0x08,0x30 ,0x10,0x00};code unsigned char Table4[]={/*-- 文字: 我 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x20,0x20,0x22,0x22,0xFE,0x21,0x21,0x20,0x20,0xFF,0x20,0x22,0xAC,0x20 ,0x20,0x00,0x04,0x04,0x42,0x82,0x7F,0x01,0x01,0x10,0x10,0x08,0x07,0x1A,0x21,0x40 ,0xF0,0x00,/*-- 文字: 好 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x10,0xF0,0x1F,0x10,0xF0,0x80,0x82,0x82,0x82,0xF2,0x8A,0x86,0x82 ,0x80,0x00,0x80,0x43,0x22,0x14,0x0C,0x73,0x20,0x00,0x40,0x80,0x7F,0x00,0x00,0x00 ,0x00,0x00,/*-- 文字: 想 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x08,0xC8,0x38,0xFF,0x18,0x68,0x08,0x00,0xFE,0x2A,0x2A,0x2A,0x2A,0xFE ,0x00,0x00,0x01,0x40,0x70,0x01,0x38,0x40,0x40,0x44,0x59,0x41,0x41,0x61,0x01,0x09 ,0x30,0x00,/*-- 文字: 你 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x80,0x40,0xF0,0x2C,0x43,0x20,0x98,0x0F,0x0A,0xE8,0x08,0x88,0x28,0x1C ,0x08,0x00,0x00,0x00,0x7F,0x00,0x10,0x0C,0x03,0x21,0x40,0x3F,0x00,0x00,0x03,0x1C ,0x08,0x00};code unsigned char Table5[]={/*-- 调入了一幅图像:C:\Documents and Settings\sammy\桌面\小新.bmp --*//*-- 宽度x高度=64x64 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0xF0 ,0xF8,0x7C,0x3C,0x1E,0x1E,0x8F,0xCF,0xCF,0xCF,0xDF,0x9F,0x9F,0x1F,0x1F,0x3F,0x3E ,0x3E,0x3E,0x7C,0x7C,0x7C,0xF8,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x20,0x10,0x08,0x08,0x1E,0x3F,0x7F,0x03 ,0x00,0x00,0x00,0x06,0x07,0x07,0x03,0x03,0x03,0x0F,0x3F,0x3F,0x7E,0x78,0x78,0x30 ,0x00,0x00,0x00,0x00,0x60,0xE0,0xF0,0x78,0x39,0x39,0x73,0xFE,0x60,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x03,0x04,0x08,0x11,0x08,0x04,0x83,0x80,0x0C,0x92,0xA2,0x44 ,0x22,0x12,0x00,0x00,0x00,0x00,0x00,0x0F,0x30,0x40,0x80,0x80,0x80,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x02,0x02,0x04,0x04,0x04,0x08,0x08,0x08,0x08,0x10,0x10,0x00 ,0x00,0x00,0x00,0x40,0x40,0x80,0x80,0x80,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00 ,0x00,0x60,0x90,0x10,0x20,0x10,0x90,0x60,0x00,0x03,0x04,0x08,0x11,0x08,0x04,0x03 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0C,0x10 ,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x01,0x06,0xF8,0x00,0x00 ,0x00,0x00,0x00,0x01,0x02,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F ,0x7F,0xFF,0xF3,0xF3,0xFE,0xFC,0xFC,0xF8,0xF8,0xF0,0xF0,0xF0,0xE0,0xE0,0xE0,0xE0 ,0xE0,0xE0,0xE4,0xE0,0xE0,0xE0,0x10,0x10,0x10,0x08,0x08,0x04,0x02,0x01,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xD8,0xD8,0xFC ,0xFC,0xFC,0xFD,0xFD,0xFF,0xF7,0xF7,0xF7,0xF7,0xFF,0xFF,0xFF,0xFF,0xF3,0xF7,0xF7 ,0xFF,0xFF,0xFF,0xFD,0xFD,0xFC,0xDC,0xD8,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0 ,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0 ,0xC0,0xC0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF ,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF ,0xFF,0xFF};code uchar Table8[]={/*-- 文字: 相 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x10,0xD0,0xFF,0x30,0x50,0x90,0x00,0xFE,0x22,0x22,0x22,0x22,0xFE ,0x00,0x00,0x04,0x03,0x00,0xFF,0x00,0x00,0x01,0x00,0xFF,0x42,0x42,0x42,0x42,0xFF ,0x00,0x00,/*-- 文字: 约 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x40,0x60,0x58,0xC7,0x60,0x18,0x40,0x20,0x58,0x8F,0x08,0x08,0x08,0xF8 ,0x00,0x00,0x10,0x32,0x13,0x12,0x0A,0x0A,0x08,0x00,0x00,0x00,0x43,0x80,0x40,0x3F ,0x00,0x00,/*-- 文字: 丛 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0xFE,0x80,0x00,0x00,0x00 ,0x00,0x00,0x20,0x30,0x2C,0x23,0x20,0x21,0x36,0x2C,0x23,0x20,0x20,0x23,0x26,0x3C ,0x28,0x00,/*-- 文字: 林 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x10,0x90,0xFF,0x90,0x10,0x00,0x10,0x10,0xD0,0xFF,0x90,0x10,0x10 ,0x10,0x00,0x08,0x06,0x01,0xFF,0x00,0x13,0x08,0x04,0x03,0x00,0xFF,0x01,0x06,0x18 ,0x08,0x00};code uchar Table9[]={/*-- 文字: 浪 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x08,0x30,0x01,0xC6,0x30,0x00,0xFC,0x94,0x95,0x96,0x94,0x94,0xFC,0x00 ,0x00,0x00,0x04,0x04,0xFE,0x01,0x00,0x00,0xFF,0x40,0x21,0x06,0x08,0x34,0x62,0xC2 ,0x40,0x00,/*-- 文字: 漫 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x20,0x81,0x66,0x00,0xC0,0x5F,0xD5,0x55,0x55,0xD5,0x55,0x5F,0xC0 ,0x00,0x00,0x04,0xFC,0x03,0x00,0x00,0x81,0x85,0x4D,0x55,0x25,0x35,0x4D,0xC5,0x41 ,0x00,0x00,/*-- 文字: 野 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x7E,0x4A,0xFE,0x4A,0x4A,0x7E,0x00,0x42,0x52,0xD2,0x6A,0x46,0xC2 ,0x40,0x00,0x22,0x22,0x22,0x1F,0x12,0x12,0x12,0x00,0x40,0x80,0x7F,0x00,0x00,0x00 ,0x00,0x00,/*-- 文字: 岭 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0xF0,0x00,0xFF,0x00,0xF0,0x40,0x20,0x10,0x2C,0x43,0x04,0x08,0x70 ,0x20,0x00,0x08,0x1F,0x08,0x07,0x04,0x07,0x01,0x05,0x09,0x11,0x29,0x65,0x03,0x01 ,0x00,0x00};void Delay_us(unsigned int DelayTime){while(DelayTime) DelayTime--;}void Delay_x10ms(unsigned char DelayTime) //***************10ms延时**********//{unsigned char i,j,k;for(i=0;i<DelayTime;i++)for(j=0;j<10;j++)for(k=0;k<120;k++) {;}}/*----------------------------------------------------------------------------下面这个函数用于液晶模块的忙信号检测。
51单片机YM12864汉字图形点阵液晶显示模块
51单片机YM12864汉字图形点阵液晶显示模块­本文以AT89C51单片机控制使用比较普遍的YM12864液晶显示器为基础,介绍了一种采用分页原理实现多级中文菜单操作的方法。
给出了YM12864主要技术参数、显示特性和核心的程序。
设计的中文菜单具有一定的通用性,只需更改其中的菜单项即可将此设计应用到家电、仪器仪表等设备上,为操作者提供友好方便的中文操作界面。
51单片机YM12864汉字图形点阵液晶显示模块-_典型应用电路图。
目前小型的显示器主要有LCD和LED,LED显示器只能显示数字和有限个英文字符,不能显示汉字,显示内容不直观,操作人员只能根据约定格式了解显示内容。
而LCD则可显示各种汉字和图形,尤其能实现中文菜单显示,为操作者提供方便友好的操作界面,并且功耗低,因此LCD得到广泛应用。
而现在市面上带中文字库的LCD比比皆是,价格适中,且大部分具有与MUC统一的标准接口,为使用LCD实现中文菜单操作提供了很大的方便。
相信更多的电子产品在提升性能的同时,设计更加人性化的中文菜单交互界面,将会使产品具有更广阔的前景。
二、YM12864液晶显示模块简介YM12864汉字图形点阵液晶显示模块,可显示汉字及图形,内置8192个中文汉字(16X16点阵)、128个字符(8X16点阵)及64X256点阵显示RAM(GDRAM)。
主要技术参数和显示特性:电源:VDD 3.3V~+5V(内置升压电路,无需负压)显示内容:128列×64行与MCU接口:8位或4位并行/3位串行多种软件功能:光标显示、画面移位、自定义字符、睡眠模式等。
其引脚功能为通用20脚LCD接口,用户指令集也为通用128*64LCD用户指令集,相关资料很容易获取。
因其内置中文字库,省去了自己造字库的工作量,而只需写入相应的汉字和字符内码即可显示所需要的汉字和字符,这在许多程序开发软件中很容易实现,如:WAVE、KEIL等。
51单片机综合学习系统之12864点阵型液晶显示篇
51单片机综合学习系统之 12864点阵型液晶显示篇大家好,通过以前的学习,我们已经对51单片机综合学习系统的使用方法及学习方式有所了解与熟悉,学会了1602字符型液晶显示的基本知识,体会到了综合学习系统的易用性与易学性,这一期我们将一起学习12864点阵型液晶显示屏的基本原理与使用方法。
点阵LCD的显示原理在数字电路中,所有的数据都是以0和1保存的,对LCD控制器进行不同的数据操作,可以得到不同的结果。
对于显示英文操作,因为英文字母种类很少,只需要8位<一字节)即可。
而对于中文,常用却有6000以上,于是我们的DOS前辈想了一个办法,就是将ASCII表的高128个很少用到的数值以两个为一组来表示汉字,即汉字的内码。
而剩下的低128位则留给英文字符使用,即英文的内码。
那么,得到了汉字的内码后,还仅是一组数字,那又如何在屏幕上去显示呢?这就涉及到文字的字模,字模虽然也是一组数字,但它的意义却与数字的意义有了根本的变化,它是用数字的各位信息来记载英文或汉字的形状,如英文的'A'在字模的记载方式如图1所示:图1 “A”字模图而中文的“你”在字模中的记载却如图2所示:图2 “你”字模图12864点阵型LCD简介12864是一种图形点阵液晶显示器,它主要由行驱动器/列驱动器及128×64全点阵液晶显示器组成。
可完成图形显示,也可以显示8×4个(16×16点阵>汉字。
管脚号管脚名称LEVER 管脚功能描述1 VSS 0 电源地2 VDD +5.0V 电源电压3 V0 - 液晶显示器驱动电压4 D/I(RS> H/L D/I=“H”,表示DB7∽DB0为显示数据D/I=“L”,表示DB7∽DB0为显示指令数据5 R/W H/L R/W=“H”,E=“H”数据被读到DB7∽DB0R/W=“L”,E=“H→L”数据被写到IR或DR6 E H/L R/W=“L”,E信号下降沿锁存DB7∽DB0R/W=“H”,E=“H”DDRAM数据读到DB7∽DB07 DB0 H/L 数据线8 DB1 H/L 数据线9 DB2 H/L 数据线10 DB3 H/L 数据线11 DB4 H/L 数据线12 DB5 H/L 数据线13 DB6 H/L 数据线14 DB7 H/L 数据线15 CS1 H/L H:选择芯片(右半屏>信号16 CS2 H/L H:选择芯片(左半屏>信号17 RET H/L 复位信号,低电平复位18 VOUT -10V LCD驱动负电压19 LED+ - LED背光板电源20 LED- - LED背光板电源表1:12864LCD的引脚说明在使用12864LCD前先必须了解以下功能器件才能进行编程。
51单片机 12864液晶显示程序
/*========================LCD12864液晶并行驱动程序==========================程序名称:12864液晶驱动程序(并行模式)================================================= ===========================*/#include <at89x52.h>#define uchar unsigned char#define uint unsigned intuchar t,p;/********************************引脚定义***********************************/#define RS P1_0 //RS=0为执行指令;RS=1为执行数据;#define RW P1_1 //读写#define E P1_2 //使能#define PSB P1_3 //低电平(串口驱动);高电平(并口驱动)#define RST P1_4 //LCD复位/********************************定义数组***********************************/uchar code title[] = {"LCD 并行接口测试"}; uchar code website[]={"qwertyuioopplkjh"}; uchar code dig[]={"0123456789"};uchar code dig2[]={0,1,2,3,':'}; ///*******************************相关子程序**********************************/void Init_lcd(); //初始化液晶void lcd_busy(); //忙标志查询void delay100us(); //100us延时程序void write(uchar x,uchar Data); //写单字节函数void Show(uchar address,uchar L,uchar STR1[]); void Show_dig(uchar address,uint number);/*******************************延时子程序**********************************/void delay100(int n){unsigned char i;while(n--)for(i=0;i<100;i++);}/*******************************LCD 忙标志查询******************************/void lcd_busy(void){uchar busy;P0=0xff;RS=0;RW=1;do{E=1;busy=P0;E=0;}while(busy>0x7f);}/*****************************写指令或数据**********************************/void write(uchar x,uchar Data){lcd_busy(); //忙查询if(x==0){RS=0;RW=0; //写单字节命令字}else if(x==1){RS=1;RW=0; //写单字节数据}E=1;P0=Data;E=0;P0=0xff;}/*******************************初始化LCD **********************************/void Init_lcd(void){delay100(20); //启动等待,等LCM讲入工作状态PSB=1; //并口驱动模式RST=0;delay100(4);RST=1; // 复位LCDwrite(0,0x30); //8 位介面,基本指令集write(0,0x0c); //显示打开,光标关,反白关write(0,0x01); //清屏,将DDRAM的地址计数器归零}/*******汉字和字符显示,参数入口:Show(地址,显示宽度,汉字数组)************/void Show(uchar address,uchar L,uchar STR1[]) {uchar i;write(0,address);for(i=0;i<L;i++)write(1,STR1[i]);}/************纯阿拉伯数字显示,参数入口:Show_dig (地址,数字)**************/void Show_dig(uchar address,uint number){uchar shi,ge;shi=number/10;ge=number%10;write(0,address);delay100(20);write(1,dig[shi]);delay100(20);write(1,dig[ge]);}/************************************主程序**********************************/void main(void){Init_lcd();TMOD=0X01;TH0=0xdc;TL0=0x00;ET0=1;TR0=1;EA=1;P3_6=0;delay100(30);Show(0x83,4,"梁浩"); //写数组里的容write(0,0x0d);delay100(30);Show(0x90,16,"电子科技协会会长"); delay100(30);Show(0x88,16,"TEL "); //写英文delay100(30);while(1){Show_dig(0x99,p); //写实时数组}}void exter() interrupt 1{TH0=0xdc;TL0=0x00;t++;if(t==20){t=0;p++;}if(p==60)p=0;}/***************************************end****** *****************************/。
51单片机12864LCD显示..
指令 R S 0 0 R W 0 0 D B 7 0 0 D B 6 0 0 D B 5 0 0 D B 4 0 0 D B 3 0 0 D B 2 0 0 D B 1 0 1 I / D C D B 0 1 X 说明 执行时间
清除显示 地址归位
将DDRAM填满“20H”,并且设定DDRAM的地址计数器(AC)到“00H” 设定DDRAM的地址计数器(AC)到“00H”,并且将游标移到开头原点位置;这个指令 并不改变DDRAM的内容
★段式液晶 ★字符图形式液晶。
本章重点:
★ 掌握12864串行和并行模式读写时序 ★ 掌握串行和并行模式的数据传输方法 ★ 理解12864显示汉字原理 ★ 理解12864显示图片原理
12.1 12864概述
我们学习是采用的LCD为STN类,像素为128*64黑白字符图形式 12864液晶屏。买LCD的时候会配带相应的驱动控制器,虽然对应的驱动 控制其型号很多,不过使用方法大同小异。12864有带字库的和不带字库 两种,不带字库的需要自己用专用软件取模,现在市面上常用的驱动控 制器都带字库。JHD529M1是一个128*64的LCD驱动控制器,可显示汉 字及图形。内置8192个中文汉字CGROM(16*16)、128个字符(ASCII 码)HCGROM(8*16)及128*64点阵显示RAM(GDRAM)。 12.1.1基本特征 低电源电压4.5-5.5V,2MHZ时钟频率,通讯方式为串并行可选,工 作温度为0-55度。 12.1.2显示内容 可以构成全中文人机互交图形界面。可以显示8*4行16*16点阵汉字, 也可以完成图形显示。并且可以实现光标显示,画面移动,自定义字符、 睡眠模式。 12.1.3通信接口 并行:8位数据线DB0-DB7、3位控制线RS,R/W,E 串行:I2C接口CS,SCLK,SDA
51单片机12864液晶字符显示
51单片机12864液晶字符显示51 单片机的12864 液晶字符显示,采用液晶的并行接法#include#include#include#define uchar unsigned char#define uint unsigned int#define LCD_data P0 //定义数据口sbit LCD_RS=P3 ; //数据命令选择端,高电平为写数据,低电平写命令sbit LCD_RW=P3;//读写控制端,高电平读信息,低电平写信息sbit LCD_EN=P3;// 使能端sbit LCD_PSB=P3;//拉高,选择并行//单片机特殊功能位声明uchar code dis1[]={“姓名:浩泉”};uchar code dis2[]={“性别:男”};uchar code dis3[]={“卡号:050817”};uchar code dis4[]={“”};void delay_1ms(uint x) //延时函数1ms{ uint i,j; for(j=0;jvoid write_cmd(uchar cmd) //写命令函数,请参考12864 液晶手册{ LCD_RS=0; //低电平,写入命令LCD_RW=0;P0=cmd; // 赋值delay_1ms(5); LCD_EN=1;//使能端拉高送入命令delay_1ms(5); LCD_EN=0;}void write_date(uchar date) //写数据{ LCD_RS=1; LCD_RW=0;P0=date; delay_1ms(5); LCD_EN=1; //使能端拉高送入数据delay_1ms(5); LCD_EN=0;}void lcd_pose(uchar X,uchar Y) //液晶显示位置函数{ uchar S,pose; switch (X) { case 0: S=0x80; //液晶第一行显示break;case 1: S=0x90; //第二行显示break;case 2: //第三行显示S=0x88; break;case 3: //第四行显示S=0x98; break;} pose=S+Y; write_cmd(pose);}。
12864无字库液晶显示程序
{'l',0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00},*/
{'m',0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F}, /*
{'b',0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00},
{'c',0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00},
2012 年 07 月 04 日(改)*//
//*****************************************************************************
**********//
#include<reg51.h> #include<intrins.h> #define NOP _nop_() #define DAT P0 #define uint unsigned int #define uchar unsigned char
{'h',0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20},
{'i',0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00},
无字库LCD12864(无时钟芯片显示时间)
/************************************************************************** 在无字库的12864LCD上显示时、分、秒;没有用时钟芯片MCU:STC89C52晶振:11.0592MHz作者:罗元俊时间:2014.06.25**************************************************************************/ #include <reg52.h>typedef unsigned char uchar;typedef unsigned int uint;#define Port P0 // 数据端口#define Disp_On 0x3f // 开显示#define Disp_Off 0x3e // 关显示#define Col_Add 0x40 // 列地址#define Page_Add 0xb8 // 页地址#define Start_Line 0xc0 // 起始页sbit RS = P2^6;sbit RW = P2^5;sbit EN = P2^7;sbit CS1 = P3^2;sbit CS2 = P3^3;uint t = 0; //全局变量:秒表(用于计数时间的增量)uchar sec,min,hour; // 全局变量:秒、分、时uchar a,b,c,d,e,f; // 秒、分、时的个位和十位uchar code HZ_tab[][32] = {{/*-- 文字: 潜--*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x20,0xC2,0x0C,0x80,0x10,0x94,0x54,0x3F,0x54,0x90,0x54,0x3F,0x54,0x94,0x10,0x00,0x04,0x04,0x7E,0x01,0x00,0x00,0xFF,0x49,0x49,0x49,0x49,0x49,0xFF,0x00,0x01,0x00},{/*-- 文字: 龙--*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x10,0x10,0x10,0x10,0xFF,0x10,0x10,0xF0,0x10,0x11,0x16,0xD0,0x10,0x10,0x00,0x80,0x40,0x20,0x18,0x06,0x41,0x20,0x10,0x3F,0x44,0x42,0x41,0x40,0x40,0x78,0x00},{/*-- 文字: 花--*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x04,0x04,0x04,0x84,0x6F,0x04,0x04,0x04,0xE4,0x04,0x8F,0x44,0x24,0x04,0x04,0x00,0x04,0x02,0x01,0xFF,0x00,0x10,0x08,0x04,0x3F,0x41,0x40,0x40,0x40,0x40,0x78,0x00},{/*-- 文字: 园--*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0xFE,0x02,0x42,0x4A,0xCA,0x4A,0x4A,0xCA,0x4A,0x4A,0x42,0x02,0xFE,0x00,0x00,0x00,0xFF,0x40,0x50,0x4C,0x43,0x40,0x40,0x4F,0x50,0x50,0x5C,0x40,0xFF,0x00,0x00},{/*-- 文字: 输--*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x88,0x68,0x1F,0xC8,0x08,0x10,0xC8,0x54,0x52,0xD1,0x12,0x94,0x08,0xD0,0x10,0x00,0x09,0x19,0x09,0xFF,0x05,0x00,0xFF,0x12,0x92,0xFF,0x00,0x5F,0x80,0x7F,0x00,0x00},{/*-- 文字: 入--*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x00,0x00,0x00,0x01,0xE2,0x1C,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x00,0x03,0x0C,0x30,0x40,0x80,0x80,0x00},{/*-- 文字: 密--*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x8C,0x44,0x04,0xE4,0x04,0x95,0xA6,0x44,0x24,0x14,0x84,0x44,0x94,0x0C,0x00,0x02,0x02,0x7A,0x41,0x41,0x43,0x42,0x7E,0x42,0x42,0x42,0x43,0xF8,0x00,0x00,0x00},{/*-- 文字: 码--*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x04,0x84,0xE4,0x5C,0x44,0xC4,0x00,0x02,0xF2,0x82,0x82,0x82,0xFE,0x80,0x80,0x00,0x02,0x01,0x7F,0x10,0x10,0x3F,0x00,0x08,0x08,0x08,0x08,0x48,0x88,0x40,0x3F,0x00}};uchar code SZ_tab[][16] = {{/*-- 文字: 0 --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00}, //0 {/*-- 文字: 1 --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00}, //1 {/*-- 文字: 2 --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00}, //2 {/*-- 文字: 3 --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00}, //3 {/*-- 文字: 4 --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00}, //4{/*-- 文字: 5 --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00}, //5 {/*-- 文字: 6 --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00}, //6 {/*-- 文字: 7 --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00}, //7 {/*-- 文字: 8 --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00}, //8 {/*-- 文字: 9 --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00}, //9 {/*-- 文字: - --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01}, //10 {/*-- 文字: : --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00} //11 };void delayms(uint xms) //延时子程序{uint x,y;for(x = xms;x > 0;x--)for(y = 2;y > 0;y--);}void DetBusybit(void) //忙位检测子程序{Port = 0xff; //读状态值时,先给数据端口赋高电平RS = 0;RW = 1;EN = 1;while(Port & 0x80); //如果LCD处于忙状态,程序就此停止delayms(2);EN = 0;}void LCD_WrCom_L(uchar com) // 写左半屏指令子程序{DetBusybit();CS1 = 1; CS2 = 0;RS = 0;RW = 0;EN = 1;Port = com;delayms(5);EN = 0;}void LCD_WrCom_R(uchar com) // 写右半屏指令子程序{DetBusybit();CS1 = 0; CS2 = 1;RS = 0;RW = 0;EN = 1;Port = com;delayms(5);EN = 0;}void LCD_WrDat_L(uchar dat) // 写左半屏数据子程序{DetBusybit();CS1 = 1; CS2 = 0;RS = 1;RW = 0;EN = 1;Port = dat;delayms(5);EN = 0;}void LCD_WrDat_R(uchar dat) // 写右半屏数据子程序{DetBusybit();CS1 = 0; CS2 = 1;RS = 1;RW = 0;EN = 1;Port = dat;delayms(5);EN = 0;}void Clear_L(void) // 左半屏清屏{uchar i,j;CS1 = 1; CS2 = 0;LCD_WrCom_L(Page_Add + 0);LCD_WrCom_L(Col_Add + 0);for(j = 0; j < 8; j++)LCD_WrCom_L(Page_Add + j);for(i = 0; i < 64; i++)LCD_WrDat_L(0x00);}void Clear_R(void) // 右半屏清屏{uchar i,j;CS1 = 0; CS2 = 1;LCD_WrCom_R(Page_Add + 0);LCD_WrCom_R(Col_Add + 0);for(j = 0; j < 8; j++)LCD_WrCom_R(Page_Add + j);for(i = 0; i < 64; i++)LCD_WrDat_R(0x00);}void Disp_HZ_L(uchar pag,uchar col,uchar n) // 显示左半屏汉字16*16 {uchar i = 0,j = 0;CS1 = 1; CS2 = 0;for(i = 0; i < 2; i++){LCD_WrCom_L(Page_Add + pag + i);LCD_WrCom_L(Col_Add + col);for(j = 0; j < 16; j++)LCD_WrDat_L(HZ_tab[n][16*i+j]);}}void Disp_SZ_L(uchar pag,uchar col,uchar n) // 显示左半屏数字8*16 {uchar i = 0,j = 0,k = 0;CS1 = 1; CS2 = 0;for(i = 0; i < 2; i++){LCD_WrCom_L(Page_Add + pag + i);LCD_WrCom_L(Col_Add + col);for(j = 0; j < 8; j++){LCD_WrDat_L(SZ_tab[n][8*i+j]);}}}void Disp_HZ_R(uchar pag,uchar col,uchar n) // 显示右半屏汉字16*16 {uchar i = 0,j = 0;CS1 = 0; CS2 = 1;for(i = 0; i < 2; i++){LCD_WrCom_R(Page_Add + pag + i);LCD_WrCom_R(Col_Add + col);for(j = 0; j < 16; j++)LCD_WrDat_R(HZ_tab[n][16*i+j]);}}void Disp_SZ_R(uchar pag,uchar col,uchar n) // 显示右半屏数字8*16 {uchar i = 0,j = 0;CS1 = 0; CS2 = 1;for(i = 0; i < 2; i++){LCD_WrCom_R(Page_Add + pag + i);LCD_WrCom_R(Col_Add + col);for(j = 0; j < 8; j++){LCD_WrDat_R(SZ_tab[n][8*i+j]);}}}void TimerInit(void) //定时器初始化函数{TMOD = 0x02; //设置定时器0为工作模式2TH0 = 0x47; //装初值TL0 = 0x47; //设定时间为0.2msEA = 1;ET0 = 1;TR0 = 1; //启动定时器0}void LCD_Init(void) // LCD初始化子程序{delayms(10);LCD_WrCom_L(Disp_Off); LCD_WrCom_R(Disp_Off);LCD_WrCom_L(Page_Add + 0); LCD_WrCom_R(Page_Add + 0);LCD_WrCom_L(Start_Line + 0); LCD_WrCom_R(Start_Line + 0);LCD_WrCom_L(Col_Add + 0); LCD_WrCom_R(Col_Add + 0);LCD_WrCom_L(Disp_On); LCD_WrCom_R(Disp_On); }void main(void){LCD_Init();TimerInit();Clear_L();Clear_R();while(1){sec = t%60; //秒钟分离min = (t/60)%60; //分钟分离hour = (t/3600)%60; //时钟分离a = sec%10; //秒钟个位分离b = (sec/10)%10; //秒钟十位分离c = min%10; //分钟个位分离d = (min/10)%10; //分钟十位分离e = hour%10; //时钟个位分离f = (hour/10)%10; //时钟十位分?Disp_HZ_L(0,32,0); // 第0页,第16列,第0个字Disp_HZ_L(0,48,1);Disp_HZ_R(0,0,2);Disp_HZ_R(0,16,3);Disp_SZ_L(2,24,2);Disp_SZ_L(2,32,0);Disp_SZ_L(2,40,1);Disp_SZ_L(2,48,4);Disp_SZ_L(2,56,10);Disp_SZ_R(2,0,0);Disp_SZ_R(2,8,6);Disp_SZ_R(2,16,10);Disp_SZ_R(2,24,2);Disp_SZ_R(2,32,7);Disp_SZ_L(4,32,f);Disp_SZ_L(4,40,e);Disp_SZ_L(4,48,11);Disp_SZ_L(4,56,d);Disp_SZ_R(4,0,c);Disp_SZ_R(4,8,11);Disp_SZ_R(4,16,b);Disp_SZ_R(4,24,a);Disp_HZ_L(6,0,4);Disp_HZ_L(6,16,5);Disp_HZ_L(6,32,6);Disp_HZ_L(6,48,7);Disp_SZ_R(6,0,11);}}void timer0(void) interrupt 1{uint i;i++;if(i == 5000) //1s时间到{t++; //秒表计时开始i = 0;}}。
12864程序(无字库)
uchar border_inf[8] = {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x80};unsigned char dan[]={0x00,0x00,0xF8,0x28,0x29,0x2E,0x2A,0xF8,0x28,0x2C,0x2B,0x2A,0xF8,0x00,0x00,0x00,0x08,0x08,0x0B,0x09,0x09,0x09,0x09,0xFF,0x09,0x09,0x09,0x09,0x0B,0x08,0x08,0x00,};unsigned char pian[]={0x00,0x00,0x00,0xFE,0x10,0x10,0x10,0x10,0x10,0x1F,0x10,0x10,0x10,0x18,0x10,0x00,0x80,0x40,0x30,0x0F,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xFF,0x00,0x00,0x00,0x00,};unsigned char ji[]={0x08,0x08,0xC8,0xFF,0x48,0x88,0x08,0x00,0xFE,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x04,0x03,0x00,0xFF,0x00,0x41,0x30,0x0C,0x03,0x00,0x00,0x00,0x3F,0x40,0x78,0x00,};unsigned char kai[]={0x40,0x42,0x42,0x42,0x42,0xFE,0x42,0x42,0x42,0x42,0xFE,0x42,0x42,0x42,0x42,0x00,0x00,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,};unsigned char fa[]={0x00,0x10,0x3E,0x10,0x10,0xF0,0x9F,0x90,0x90,0x92,0x94,0x1C,0x10,0x10,0x10,0x00,0x40,0x20,0x10,0x88,0x87,0x41,0x46,0x28,0x10,0x28,0x27,0x40,0xC0,0x40,0x00,0x00,};unsigned char ban[]={0x10,0x10,0xD0,0xFF,0x50,0x90,0x00,0xFE,0x62,0xA2,0x22,0x21,0xA1,0x61,0x00,0x00,0x04,0x03,0x00,0x7F,0x00,0x11,0x0E,0x41,0x20,0x11,0x0A,0x0E,0x31,0x60,0x20,0x00,};unsigned char w[]={0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,};uchar corp_pic[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0xF8,0xF8,0x08,0x00, 0x00,0x00,0xF8,0xF8,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x8C,0xBC, 0xF8,0xF8,0xA0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0x80,0x00, 0x00,0x00,0x00,0x00,0x08,0x38,0xF0,0xE0,0x40,0x00,0x00,0x00,0xC0,0xF8,0xFC,0xBC, 0x88,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xC0,0x60,0x60,0x40,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x08,0x38,0xF0,0xF0,0xE0,0x00,0x00,0x20,0x20,0x20,0x20,0xE0, 0xE0,0xE0,0x20,0x20,0x20,0x20,0xF0,0xF0,0xF0,0x20,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xFF,0xFF,0xFF,0x00,0x00, 0x00,0x00,0xFF,0xFF,0xFF,0x40,0x60,0x20,0x30,0x18,0x1C,0x0E,0x0E,0x04,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0xF8,0xF8,0x10,0x10,0x10,0x10,0x10, 0x10,0x10,0x10,0x10,0x10,0x10,0x18,0xFC,0xFC,0x18,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x02,0x0E,0x3C,0x78,0x70,0x00,0xF0,0xFE,0x1E,0x1C,0x0F,0xFF,0xFF,0x7C,0x08,0x18,0x38,0xE8,0xE8,0xC8,0x08,0x08,0x08,0xFC,0xFC,0x0C,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x20,0x20,0x20,0x20,0x30,0xF0,0xF0,0x20,0x00,0x40,0x40,0x40,0x40,0xFF, 0xFF,0xFF,0x40,0x60,0x20,0x60,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0xFF,0xFF,0xFF,0x00,0x00, 0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xE0,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xDF,0xCF,0xC4,0x84,0x04,0x04,0xFC, 0xFC,0xFC,0x04,0x04,0x04,0x44,0xC4,0x8F,0x8F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x40,0xC0,0xE0,0xF8,0xFF,0x0F,0x02,0x02,0xC2,0xFF,0xFF,0x1F,0x02,0x02, 0x02,0x3A,0xFA,0xF2,0x02,0x02,0x02,0xFE,0xFF,0xFF,0x02,0x02,0x03,0x03,0x02,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, 0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x0F,0x3F,0x7C,0xE0,0xE0,0xF8,0x38,0x00,0x00, 0x00,0x00,0x02,0x06,0x06,0x07,0x03,0x01,0x01,0x00,0x00,0x3F,0x3F,0x3F,0x00,0x00,0x00,0x00,0x1F,0x1F,0x3F,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x3F,0x1F,0x18,0x00,0x00,0x00,0x20,0x20,0x30,0x18,0x0C,0x0E,0x07,0x03,0x11,0x10,0x10,0x30,0x70,0x7F, 0x7F,0x3F,0x00,0x00,0x00,0x00,0x00,0x03,0x07,0x0F,0x3E,0x3E,0x08,0x00,0x00,0x00, 0x00,0x00,0x00,0x1C,0x3F,0x3F,0x30,0x00,0x00,0x01,0x03,0x03,0x03,0x02,0x02,0x02, 0x02,0x12,0x12,0x12,0x32,0x72,0x72,0x7F,0x3F,0x07,0x02,0x03,0x01,0x01,0x00,0x00, 0x00,0x00,0x04,0x0E,0x0F,0x03,0x01,0x01,0x01,0x03,0x06,0x0C,0x0C,0x18,0x18,0x1B, 0x1B,0x19,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x18,0x19,0x19,0x19,0x08,0x08, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xE0,0xFC,0x3C,0x18,0x08,0x00,0x00,0x00, 0xFC,0xFC,0xF8,0x08,0x00,0x00,0x00,0x80,0xC0,0xE0,0xE0,0x60,0x40,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xE0,0xE0,0xC0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xC0, 0xC0,0xC0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xC0,0xE0,0xE0,0x40,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xF0,0xF0,0x70,0x30,0x00, 0x00,0x00,0x18,0xF8,0xE8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xF8,0xF8,0xF0,0x00,0x00,0x00,0x00, 0x00,0x00,0x20,0x30,0x18,0x0C,0x07,0xFF,0xFF,0xFF,0x41,0x40,0x40,0x60,0x20,0x30, 0x17,0xFF,0xFF,0x0C,0x06,0x06,0x03,0x03,0x01,0x00,0x00,0x00,0xF8,0xF8,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, 0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0x78,0x1E,0x0F,0x07,0x01,0x00,0x80,0xC0, 0xC0,0x80,0x80,0x00,0x03,0x0F,0x1E,0x78,0xF0,0xE0,0xC0,0x80,0x80,0x00,0x00,0x00, 0x00,0x00,0x00,0x04,0x04,0x04,0x04,0xC4,0xC4,0x84,0x84,0x84,0x84,0x84,0x84,0x84, 0x84,0xC4,0xC4,0x86,0x06,0x06,0x04,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00, 0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x47,0x47,0x47,0x40,0x40,0x40,0x40,0x40,0xFC, 0xFC,0xFF,0x43,0x43,0x43,0x43,0x43,0x43,0x43,0x43,0x43,0x43,0x63,0x63,0x41,0x00, 0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xFF, 0xFF,0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00, 0x00,0x00,0x04,0x06,0x03,0x01,0x01,0x00,0x00,0x00,0xC0,0xE0,0x78,0x3E,0x1F,0x07, 0x03,0x00,0x00,0x20,0xE0,0xC0,0x80,0x00,0x00,0x01,0x03,0x03,0x03,0x01,0x01,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x40,0x40,0x40,0x40,0x40,0x40,0x40, 0x40,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x7F,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x3F,0x3F,0x1F,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x07, 0x07,0x07,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x1F,0x1F,0x1F,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x1C,0x1E,0x1F,0x1B,0x18,0x18,0x08,0x08,0x08, 0x08,0x08,0x08,0x08,0x08,0x09,0x0F,0x1F,0x7E,0x7C,0x30,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x01,0x01,0x01,0x00,0x10,0x10,0x30,0x78,0x7F,0x3F,0x0F,0x00,0x00,0x00,0x00 };uchar corp_pic1[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x70,0xFC,0xFC,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xF0,0xE0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xF0,0xF0,0xC0,0x80,0xE0,0xFF,0xFF,0xFF,0xFF,0x78,0x78,0xF8,0xF0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xF8,0xF8,0xF8,0xF0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x06,0x3F,0x3F,0x9C,0x9C,0x3E,0x3C,0x38,0xF8,0xFC,0xFE,0xFE,0xFE,0xFE,0xFC,0xC0,0x80,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x7E,0xFF,0xE1,0x00,0xC0,0xF8,0xFC,0xFC,0xE4,0xE2,0xC2,0xC2,0xE1,0xA1,0x33,0xF3,0xF3,0xF0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x3B,0x38,0x38,0x1E,0x9F,0x87,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0xC0,0xFF,0xFF,0xFF,0xFF,0xFB,0xF9,0xF8,0xF8,0xF8,0x78,0x78,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xF8,0xFC,0xFF,0xFF,0x7F,0x3F,0x3F,0x1F,0x8F,0x8F,0xC3,0xC3,0xE3,0xE1,0xE1,0x31,0x31,0x73,0xE3,0xE3,0x7F,0x3F,0x00,0x00,0x00,0x00,0x00,0x10,0x78,0xF8,0xF0,0xF0,0xF0,0xFF,0xFF,0xFF,0xDF,0xFF,0xBF,0xB3,0xB0,0x99,0x9B,0x9F,0x9F,0x9F,0x9E,0x86,0x81,0x81,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x70,0x70,0x78,0x78,0x78,0x78,0x78,0x78,0x78,0x78,0x78,0xF8,0xF8,0xF8,0xFF,0xBF,0x3F,0x3D,0xFC,0xFC,0xFC,0xFC,0x7F,0x1F,0x1F,0x1F,0x1E,0x0F,0x0E,0x0E,0x1E,0x1F,0x0E,0x04,0x00,0x00,0x00,0x00,0x00,0x81,0x87,0xC7,0xE7,0xFF,0xFF,0xFF,0xFF,0xFF,0x3F,0x1F,0x01,0x70,0xF0,0xF0,0xF0,0xF0,0xE0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x67,0xE3,0xE0,0xE0,0xE0,0xE1,0xE3,0xF3,0xF8,0xFE,0xFF,0xFB,0xF0,0x70,0x70,0x70,0x70,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x07,0x07,0x07,0x07,0x07,0x0F,0x0F,0x07,0x07,0x07,0x0F,0x0F,0x0F,0x0F,0x1F,0x1F,0x0F,0x0F,0x0F,0x07,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x0E,0x1E,0x1E,0x1E,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x07,0x07,0x07,0x07,0x0F,0x0F,0x1E,0x1E,0x3C,0x3C,0x18,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x07,0x07,0x07,0x07,0x03,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x07,0x0F,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x1C,0x3C,0x3C,0x3C,0x3C,0x1F,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};程序如下:*******************************************************************************主程序:#include <reg52.h>#include <LCD_12864.h>main() //主程序{unsigned char i=0;while(1){init_lcd();display_imge1();delay(30000);Msg(0);delay(30000);display_imge2();delay(30000);Disp_H_Line();delay(10000);Disp_V_Line();delay(10000);Msg(1);delay(30000);}}驱动程序//**********************LCD——12864显示程序**************// #include <reg52.h>#include <string.h>#include <math.h>#include <LCD_12864.h>#include <LCD_12864_data.h>#define Disp_On 0x3f //开显示#define Disp_Off 0x3e //关显示#define Col_Add 0x40 //#define Page_Add 0xb8 //页起始地址#define Start_Line 0xc0 //行起始地址#define Lcd_Bus P0 // MCU P0<------> LCMsbit Di =P2^0; //Data or Instrument Select RSsbit RW =P2^1; //Write or Read R/Wsbit Enable =P2^2; //6800 mode Enable single Esbit Mcs =P2^3; //Master chip enable CS1sbit Scs =P2^4; //Slave chip enable CS2sbit Lcd_Rst=P2^5; //Lcm reset RSTvoid delay(unsigned int t) //延时子程序{unsigned int i,j;for(i=0;i<t;i++)for(j=0;j<10;j++);}void write_com(unsigned char cmdcode) //写指令{Di=0;RW=0;Lcd_Bus=cmdcode;delay(0);Enable=1;delay(0);Enable=0;}void write_data(unsigned char Dispdata) //写数据{Di=1;RW=0;Lcd_Bus=Dispdata;delay(0);Enable=1;delay(0);Enable=0;}void frame() //{unsigned char i;Mcs=1;Scs=1;write_com(Page_Add+0);write_com(Col_Add+0);for(i=0;i<64;i++) write_data(0x01);write_com(Page_Add+7);write_com(Col_Add+0);for(i=0;i<64;i++) write_data(0x80);for(i=0;i<8;i++){Mcs=1;Scs=1;write_com(Page_Add+i);write_com(Col_Add+63);write_data(0xff);Mcs=1;Scs=1;write_com(Page_Add+i);write_com(Col_Add+0);write_data(0xff);}}void Clr_Scr(){unsigned char j,k;Mcs=1;Scs=1;write_com(Page_Add+0);write_com(Col_Add+0);for(k=0;k<8;k++){write_com(Page_Add+k);for(j=0;j<64;j++)write_data(0x00);}}void Disp_Img(unsigned char code *img) //显示图片{unsigned char j,k;Clr_Scr();for(k=0;k<8;k++){Mcs=1;Scs=0;delay(10);write_com(Page_Add+k);write_com(Col_Add+0);for(j=0;j<64;j++) write_data(img[k*128+j]);Mcs=0;Scs=1; delay(10);write_com(Page_Add+k);write_com(Col_Add+0);for(j=64;j<128;j++) write_data(img[k*128+j]);}}void Disp_H_Line() //显示行线{unsigned char i,j;Mcs=1;Scs=1;write_com(Disp_On);write_com(Page_Add);write_com(Start_Line);write_com(Col_Add);for(j=0;j<8;j++){write_com(Page_Add+j);write_com(Col_Add+0);// write_com(Start_Line+0);for(i=0;i<64;i++)write_data(0x55);}}void Disp_V_Line() //显示列线unsigned char i,j;write_com(Disp_On);write_com(Page_Add);write_com(Start_Line);write_com(Col_Add);for(j=0;j<8;j++){write_com(Page_Add+j);write_com(Col_Add+0);write_com(Start_Line+0);for(i=0;i<32;i++){write_data(0x00);write_data(0xff);}}}void hz_disp16(unsigned char pag,unsigned char col, unsigned char code *hzk) //行列显示{unsigned char j=0,i=0;for(j=0;j<2;j++){write_com(Page_Add+pag+j); //第3、4行write_com(Col_Add+col); //列选for(i=0;i<16;i++) write_data(hzk[16*j+i]);}}void init_lcd() //显示初始化{Lcd_Rst=0;delay(100);Lcd_Rst=1;delay(100);Mcs=1;Scs=1;delay(100);write_com(Disp_Off);write_com(Page_Add+0);write_com(Start_Line+0);write_com(Col_Add+0);write_com(Disp_On);}void Msg(int flg)Clr_Scr();frame();if(flg==0){ //显示“延安大学”Mcs=1;Scs=0;hz_disp16(3,32,yan);delay(4000);hz_disp16(3,48,an);delay(4000);Mcs=0;Scs=1;hz_disp16(3,0,da);delay(4000);hz_disp16(3,16,xue);delay(4000);}else if(flg==1){ //显示“测试完毕”Mcs=1;Scs=0;hz_disp16(3,32,ce);hz_disp16(3,48,shi);Mcs=0;Scs=1;hz_disp16(3,0,wan);hz_disp16(3,16,bi);}}void display_imge1(){Disp_Img(FirstPage);}void display_imge2(){Disp_Img(SecondPage);}字模数据#include <reg52.h>char code yan[]={0x02,0x22,0x72,0x2E,0xE2,0x00,0x04,0xE4,0x04,0x04,0xFC,0x42,0x42,0x42,0x00,0x00,0x40,0x23,0x14,0x08,0x17,0x20,0x20,0x47,0x44,0x44,0x47,0x44,0x44,0x44,0x44,0x00/*"延",0*/};char code an[]={0x80,0x90,0x8C,0x84,0x84,0xF4,0xA5,0x86,0x84,0x84,0x84,0x84,0x94,0x8C,0x84,0x00,0x80,0x80,0x80,0x40,0x47,0x28,0x28,0x10,0x28,0x24,0x43,0xC0,0x40,0x00,0x00,0x00/*"安",1*/};char code da[]={0x20,0x20,0x20,0x20,0x20,0x20,0xA0,0x7F,0xA0,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x01,0x06,0x08,0x30,0x60,0xC0,0x40,0x00/*"大",2*/};char code xue[]={0x40,0x30,0x10,0x12,0x5C,0x54,0x50,0x51,0x5E,0xD4,0x50,0x18,0x57,0x32,0x10,0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x02,0x02,0x02,0x02,0x02,0x02,0x00/*"学",3*/};char code ce[]={0x08,0x31,0x86,0x60,0x00,0xFE,0x02,0xF2,0x02,0xFE,0x00,0xF8,0x00,0x00,0xFF,0x00,0x04,0xFC,0x03,0x00,0x80,0x47,0x30,0x0F,0x10,0x67,0x00,0x07,0x40,0x80,0x7F,0x00,/*"测",0*/};char code shi[]={0x40,0x42,0xDC,0x08,0x00,0x90,0x90,0x90,0x90,0x90,0xFF,0x10,0x12,0x1C,0x10,0x00,0x00,0x00,0x7F,0x20,0x10,0x20,0x20,0x1F,0x10,0x10,0x01,0x06,0x18,0x20,0x78,0x00,/*"试",0*/};char code wan[]={0x00,0x90,0x8C,0xA4,0xA4,0xA4,0xA5,0xA6,0xA4,0xA4,0xA4,0xA4,0x94,0x8C,0x04,0x00, 0x00,0x80,0x40,0x20,0x18,0x07,0x00,0x00,0x00,0x3F,0x40,0x40,0x40,0x70,0x00,0x00,/*"完",0*/};char code bi[]={0x00,0x00,0xFF,0x88,0x48,0x28,0x08,0x80,0x7F,0x88,0x88,0x88,0x84,0x84,0xE0,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0xFF,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,/*"毕",0*/};unsigned char code FirstPage[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x70,0xFC,0xFC,0x7C,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0xC0,0xF0,0xE0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xF0,0xF0,0xC0,0x80,0xE0,0xFF,0xFF,0xFF,0xFF,0x78,0x78,0xF8,0xF0,0xE0,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xF8,0xF8,0xF8,0xF0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x06,0x3F,0x3F,0x9C,0x9C,0x3E,0x3C,0x38,0xF8,0xFC,0xFE,0xFE,0xFE,0xFE,0xFC,0xC0,0x80,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x7E,0xFF,0xE1,0x00,0xC0,0xF8,0xFC,0xFC,0xE4, 0xE2,0xC2,0xC2,0xE1,0xA1,0x33,0xF3,0xF3,0xF0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x3B,0x38,0x38,0x1E,0x9F,0x87,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0xC0,0xFF,0xFF,0xFF,0xFF,0xFB,0xF9,0xF8,0xF8,0xF8,0x78,0x78,0x30,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xF8,0xFC,0xFF,0xFF,0x7F,0x3F,0x3F,0x1F,0x8F,0x8F,0xC3,0xC3,0xE3,0xE1,0xE1,0x31,0x31,0x73,0xE3,0xE3,0x7F,0x3F,0x00,0x00,0x00, 0x00,0x00,0x10,0x78,0xF8,0xF0,0xF0,0xF0,0xFF,0xFF,0xFF,0xDF,0xFF,0xBF,0xB3,0xB0, 0x99,0x9B,0x9F,0x9F,0x9F,0x9E,0x86,0x81,0x81,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x70,0x70,0x78,0x78,0x78,0x78,0x78,0x78,0x78,0x78,0x78,0xF8,0xF8,0xF8,0xFF,0xBF,0x3F,0x3D,0xFC,0xFC,0xFC,0xFC,0x7F,0x1F,0x1F,0x1F,0x1E, 0x0F,0x0E,0x0E,0x1E,0x1F,0x0E,0x04,0x00,0x00,0x00,0x00,0x00,0x81,0x87,0xC7,0xE7, 0xFF,0xFF,0xFF,0xFF,0xFF,0x3F,0x1F,0x01,0x70,0xF0,0xF0,0xF0,0xF0,0xE0,0xC0,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x67,0xE3,0xE0,0xE0,0xE0,0xE1,0xE3, 0xF3,0xF8,0xFE,0xFF,0xFB,0xF0,0x70,0x70,0x70,0x70,0x60,0x00,0x00,0x00,0x00,0x00, 0x00,0x06,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x07,0x07,0x07,0x07,0x07,0x0F,0x0F,0x07,0x07,0x07,0x0F,0x0F,0x0F,0x0F,0x1F,0x1F,0x0F,0x0F,0x0F,0x07,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x0E,0x1E,0x1E,0x1E,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x07,0x07,0x07,0x07,0x0F,0x0F,0x1E,0x1E,0x3C,0x3C,0x18,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x07,0x07,0x07,0x07,0x03,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x07,0x0F,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x1C,0x3C,0x3C,0x3C,0x3C,0x1F,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"C:\Documents and Settings\Administrator\桌面\延安大学字.bmp",0*/};unsigned char code SecondPage[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0xC0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xC0,0x80, 0x00,0x00,0xC0,0xC0,0xC0,0x80,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x03,0xC1,0xF1,0xFD,0xFF,0xDF,0xC7,0xC0,0x12,0xF3,0xF3,0xF3,0x03,0xFF,0xFF, 0xFF,0x41,0x41,0x41,0x41,0x00,0x00,0x00,0x00,0x00,0x1E,0x1E,0x1E,0x02,0x02,0x02, 0xC2,0xF2,0xF2,0x73,0x23,0x03,0x02,0x02,0x02,0x02,0x02,0x3E,0x3E,0x3E,0x00,0x00, 0x00,0x00,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0xFF,0xFF,0xFF,0xFF,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00,0x00,0x00,0x78,0x78,0x78,0x78,0x8B,0x8B,0x8B, 0x8A,0x88,0x89,0x8B,0x89,0x89,0x8C,0x8F,0x8F,0x8F,0x89,0x78,0x78,0x78,0x78,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x1C,0xBC,0xF8,0xFE,0xFF,0x9F,0x81,0x20,0x3F,0x3F,0x3F,0x20,0x3F,0x3F, 0x3F,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x03,0x03,0x03,0x03,0x13,0x1F,0x3F,0x3F,0xB7,0xF3,0xE3,0xE3,0xF3,0xFF,0xFF,0x9F,0x87,0x03,0x03,0x03,0x03,0x03,0x00, 0x00,0x00,0x00,0x00,0x80,0xC0,0xC0,0xF0,0xF8,0x7E,0x3F,0x0F,0x0F,0x1F,0x7C,0xF8, 0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10, 0x10,0x10,0x10,0xFC,0xFE,0xFE,0x17,0x13,0x13,0x11,0x11,0x10,0x10,0x10,0x10,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0x80, 0x00,0x06,0x07,0x07,0x03,0x01,0x81,0x81,0x83,0x83,0x83,0x83,0xC6,0xC6,0xC6,0x86, 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x00,0x02,0x0E,0xCE,0xC6,0x07,0xC7, 0x83,0x03,0x03,0x01,0x01,0x80,0x81,0x01,0x03,0x03,0x07,0x87,0x87,0x02,0x00,0x00,0x81,0x81,0x03,0x07,0x07,0x03,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x07,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0xFF,0xFF,0x8D,0x8D,0x8D,0x8C,0xFC,0xFC,0x8C,0x8C,0x80,0x80,0x00,0x80,0x80,0x80,0xFF,0xFF,0x99,0x99,0x99,0x99,0xF8,0xF8,0x98,0x98,0x80,0x80,0x00,0x33,0x33,0xFF,0xFF,0x33,0x00,0x16,0x36,0xA6,0xFF,0xFF,0xC6,0x66,0x37,0x16,0x00,0x00,0x00,0xFF,0xFF,0x18,0x18,0x18,0x00,0xFF,0xFF,0x30,0x18,0x1C,0x0C,0x00,0x00,0x00,0xA1,0xA1,0xAA,0xEA,0xFF,0xBF,0xAA,0xAA,0xFF,0xFF,0xAA,0xAA, 0xA1,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x19,0x19,0x0D,0x0D,0x07,0x03,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x07,0x05,0x0D,0x19,0x11,0x01,0x00,0x0C,0x0C,0x07,0x07,0x06,0x00,0x06,0x03,0x19,0x1F,0x0F,0x01,0x03,0x06,0x04,0x00,0x00,0x00,0x1F,0x1F,0x0C,0x06,0x06,0x00,0x0F,0x1F,0x18,0x18,0x18,0x1E,0x0C,0x00,0x00,0x00,0x10,0x10,0x1B,0x1B,0x0C,0x06,0x06,0x0C,0x8B,0x9B,0x18,0x10,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x00,0xC0,0xC0,0x00,0x00,0x00,0x80,0xC0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0, 0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x18,0x18,0xF8,0xF9,0x03,0x00,0x01,0xF1,0xF1,0x31,0x31,0x31,0x3F,0x3F,0x00,0x00,0x00,0x30,0x18,0x3C,0x36,0xF3,0xF1,0x30,0x30,0x33,0xF7,0xFE,0x1C,0x38,0x10,0x00,0x00,0xFF,0xFF,0xD8,0xDF,0xDF,0x18,0x7F,0x7F,0xCB,0xFF,0xFF,0xCB,0x7F,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x1F,0x0C,0x06,0x00,0x0F,0x1F,0x18,0x18,0x18,0x18,0x1C,0x1C,0x00,0x00,0x08,0x18,0x0C,0x06,0x03,0x01,0x00,0x18,0x18,0x0F,0x07,0x00,0x00,0x00,0x00,0x18,0x0F,0x03,0x00,0x1F,0x1F,0x06,0x06,0x07,0x07,0x06,0x1F,0x1F,0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00,/*"C:\Documents and Settings\Administrator\桌面\乒乓球记分牌.bmp",0*/};/×××××××××××××××××××××××××××××××××××××××库函数.h××××××××××××××××××××××××××××××××××××××/ void delay(unsigned int t);。
国家单片机师资培训-TG12864液晶(无字库)
无锡机电高等职业技术学校
(4)TG12864LCD的时序 TG12864LCD的时序
1、写操作时序
无锡机电高等职业技术学校 2、读操作时序
无锡机电高等职业技术学校
(5)屏幕显示与DDRAM地址映射关系 屏幕显示与DDRAM地址映射关系 DDRAM
Y1 Y2 Y3 Y4 ………… Y62 Y63 Y64 Line 0 X=0 Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 Line 7 ………… ………… ………… X=7 Line60 Line61 Line62 Line63 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 ………… ………… ………… ………… 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 DB4 DB5 DB6 DB7 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 ………… ………… ………… ………… ………… ………… ………… ………… 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7
无锡机电高等职业技术学校 7、读显示数据 CODE:R/W D/I DB7 DB6 H H D7 D6
无字库PG12864液晶屏技术资料
10/20
PG12864LRS-JNN-H 技术手册(完整版)
原创技术资料
设置显示超始说明
CS1(左半屏)
CS2(右半屏)
12864 是由两片 64*64 组成,使用 CS1/CS2 使能(可同时使能)。每半屏 8 页,每页中字节数据由低到高。
驱动程序(C 语言)
/*********************************************************************************************
#include <reg52.h>
// 包含头文件
11/20
PG12864LRS-JNN-H 技术手册(完整版)
原创技术资料
#include <string.h> //用于指针
/*********************************************************************************************
出品
程序名 Dy-12864LC 驱动程序
制作人 杜洋
日期
2007-4-18
参数
MCS-51
12MHZ
PG12864LRS-JNN-H
/*********************************************************************************************
品名 型号 规格
图形液晶显示屏模块 PG12864LRS-JNN-H 128 X 64 STN LCD 点阵
文档制作 创建日期 版本信息
杜洋 () 2007-4-20 V1.0
51单片机控制LCD12864液晶屏显示图形菜单
51单片机控制LCD12864液晶屏显示图形菜单想了很久,每次做菜单都受限于12864字符模式的各种限制,比如字体大小,不能显示图标等等,没有任何效果,这次就来个彻底的解脱,写一个单函数就能完成所有功能的函数,只需要2个图片就能完成任意菜单内容的菜单,可以有2的8次方=256个选择结果,应该能满足所有的要求了吧?菜单的内容就是图片的内容,因此可以显示任意大小的图形文字混合的菜单条目,比如使用字符模式,一屏只能显示4行菜单(64/16=4),且只能显示汉字和字符等,显示位置等等的都受限,而这个方法可以显示比如12*12(64/12=5行)的字符,8*8(64/8=8行)的字符,甚至不是字符,可以是图标+文字+任意其他的图像,只要是图片能显示的,都可以。
哈哈,比较复杂,现在只写了一少半,预期能够提供多种显示效果,希望我能完成。
void Lcd_Draw_BmpMenu(UINT8 *pMenu,UINT8*pTitleBmp,UINT8 *pMenuBmp){/*使用2张图片作为纯图形菜单来选择和操作,返回被选择的项,pMenu是一个指向菜单的各种参数的结构体的指针,pTitleBmp指向作为菜单标题的一张图片,pMenuBmp指向作为菜单内容的图片(液晶的控制芯片是ST7920)yx-->;>;|\|/*/xdata struct { //除非另有说明x坐标均为大列的坐标,一个大列是16个像素,一行共有8大列数据//========= 以下是入参基本参数,一旦确定,最好不要随意更改 ======UINT8 Title_x;//标题图片在屏幕上的显示起始位置X UINT8 Title_y;//标题图片在屏幕上的显示起始位置Y UINT8 Title_Len_x;//标题图片的宽UINT8 Title_Len_y;//标题图片的高UINT8 Menu_x;//菜单在屏幕上的显示起始位置XUINT8 Menu_y;//菜单在屏幕上的显示起始位置YUINT8 Menu_End_y;//菜单在屏幕上的显示结束位置Y UINT8 Menu_Bmp_x;//菜单图片的宽UINT8 Menu_Bmp_y;//菜单图片的高UINT8 Menu_Item_Height;//每一菜单项的高度(像素为单位)UINT8 Line_x;//最后下划线的起始坐标xUINT8 Line_y;//最后下划线的起始坐标YUINT8 Line_Len;//最后下划线的长度,如果为0,则表示不画出这条线(像素为单位)//====== 以下是菜单的风格设置 ========UINT8 Scroll_Speed;//菜单滚动的速度,0~9个级别,越低越快,越高越慢(液晶屏显示速度有快有慢,调整这个参数用于适用不同的液晶屏UINT8 Continue_Scroll;//指定菜单是否可以形成一个连续滚动选择的效果;0不连续,背景和反白位置都会根据实际情况滚动 1菜单连续滚动,反白位置不动UINT8 RePaint;//=0不重画菜单,=1重画整个菜单的图像,一般都是首次调用本函数的时候置1,用于画出整个菜单,以后调用置0就可以了UINT8 MenuEffect;//菜单运动的效果;0没有任何效果,只是最普通的菜单形态,1平滑滚动,2平滑滚动,具有惯性效果,3具有减速效果,没有惯性效果,4具有减速和惯性效果//====== 以下用于控制菜单的选择参数 =======UINT8 Last_Select_Item;//上次执行本函数后,所选择的菜单项UINT8 Select_Item;//本次执行本函数,要选择的菜单项}M;//============== 以下是变量定义 =============== UINT8 xdata Menu_Item_Count;//总共有几个菜单项UINT8 xdata Menu_Screen_Count;//当前一屏最多可以显示几个菜单项UINT8 xdataMenu_Box_x,Menu_Box_y,Menu_Box_End_x,Menu_Box_End _y;//需要刷新的区域的坐标UINT8 *pMenu_Box_Bmp;//需要显示的菜单项的指针StructCopy(&M.Title_x,pMenu,19);//把参数复制到本函数内,便于操作Menu_Item_Count=M.Menu_Bmp_y/M.Menu_Item_Height;/ /总共有几个菜单项Menu_Screen_Count=(M.Menu_End_y-M.Menu_y)/M.Menu_ Item_Height;//一屏最多可以显示多少项菜单//---------------------------------------------------------------------------if(M.RePaint==1)//如果需要重画整个菜单图像{Lcd_Draw_BMP(M.Title_x,M.Title_y,M.Title_x+M.Title_Len_x,M.Title_y+M.Title_Len_y,pTitleBmp);//画出标题的图片if(M.Line_Len!=0)Lcd_DrawRowLine(M.Line_x,M.Line_y,M.Line_Len,1);/ /画出最下面的线}//---------------------------------------------------------------------------//-----------需要刷新的图像的区域Menu_Box_x=M.Menu_x;Menu_Box_y=M.Menu_y;Menu_Box_End_x=M.Menu_x+M.Menu_Bmp_x;Menu_Box_End_y=M.Menu_End_y;。
12864的液晶显示程序(无字库)
12864的液晶显示程序(无字库)12864.h#ifndef __12864_H__#define __12864_H__#include#include/***************************************利用I/O口模拟点阵液晶所需时序点阵液晶控制端口定义,需根据硬件适当改变****************************************/sbit LCD_RS = P2^0;//控制端口定义sbit LCD_RW = P2^1;sbit LCD_E = P2^2;sbit LCD_CSA = P2^3;//H选通,即高电平有效sbit LCD_CSB = P2^4;#define LCD_Data P0//LCD数据端口8位#define R 1#define L 2/*****************************************函数声明*****************************************/void ReadStatusLCD(unsigned char select);//从LCD读出忙标志位unsigned char ReadDataLCD(unsigned char select);//从LCD 读出数据void WriteDataLCD(unsigned char WDLCD,unsigned char select);//向LED写入数据void WriteCommandLCD(unsigned char WCLCD , unsigned char BusyC,unsigned char select);//向LCD写入命令void LcdReset(void) ;//初始化函数,完成液晶模块的初始设置void clear_LCD(unsigned char select);//清屏函数void Clr_All_Lcd(void);//全清屏函数void set_XY(unsigned char Column,unsigned char Page);//设置数据写入或读出的地址,通过页号和列数可以唯一确定一个地址void xy_Write(unsigned char Column,unsigned char Page,unsigned char dataW);//向指定行列写数据void LcmPutDots(unsigned char Column,unsigned char Page, unsigned char DotByte );//显示点void whiteword(unsigned char Column,unsigned char Page, const unsigned char puts[][16] );//显示16×16点阵的编码void WhiteWord_Com(unsigned char Column,unsigned char Page,unsigned char C_num,unsigned char V_num, unsigned char * puts );//通用的显示函数void Drawing_dot(unsigned char x,unsigned char y);void Drawing_line_vertical(unsigned x);#endif12864.c/****************************************************LCD12864点阵液晶屏,通过I/O口直接控制,采用模拟时序控制****************************************************/#include"12864.h"#include/*********************************************************** 功能:从LCD读取状态位变量:select用于选择LCD屏的左右,1选择左屏,2选择右屏***********************************************************/ void ReadStatusLCD(unsigned char select){switch(select){case 1:{LCD_CSA=1;LCD_CSB=0;break;}//左case 2:{LCD_CSA=0;LCD_CSB=1;break;}//右default: break;}LCD_Data = 0xff;//置位输入口,已实现输入LCD_RS=0;LCD_RW=1;LCD_E=1;//高电平读取数据//_nop_(); //若晶振速度高,可在此作延时处理while(LCD_Data&0x80);//最高位为忙标志,检测忙信号状态LCD_E=0;//_nop_(); //若晶振速度高,可在此作延时处理}/*********************************************************** 功能:从LCD读取数据变量:select用于选择LCD屏的左右,1选择左屏,2选择右屏***********************************************************/ unsigned char ReadDataLCD(unsigned char select){unsigned char dataR;LCD_Data = 0xff;//置位输入口,已实现输入switch(select){case 1:{LCD_CSA=1;LCD_CSB=0;break;}//左case 2:{LCD_CSA=0;LCD_CSB=1;break;}//右default: break;}LCD_RW=1;LCD_RS=1;LCD_E = 1;// 操作允许脉冲信号,高电平读出//_nop_(); //若晶振速度高,可在此作延时处理dataR = LCD_Data;LCD_E= 0;return dataR;}/***********************************************************功能:向LCD写入数据参数:WDLCD待写入的字符数据select用于选择LCD屏的左右,1选择左屏,2选择右屏***********************************************************/void WriteDataLCD(unsigned char WDLCD,unsigned char select){switch(select){case 1:{LCD_CSA=1;LCD_CSB=0;break;}//左case 2:{LCD_CSA=0;LCD_CSB=1;break;}//右default: break;}ReadStatusLCD(select);//检测忙标志LCD_RS = 1;LCD_RW = 0;LCD_Data = WDLCD;LCD_E = 1;//_nop_(); //若晶振速度高,可在此作延时处理LCD_E = 0; //下降沿写入数据//_nop_(); //若晶振速度高,可在此作延时处理}/***********************************************************功能:向LCD写入命令参数:WDLCD待写入的字符数据BusyC是否要检查忙标志位选择标志,1为进行,0为不检测select用于选择LCD屏的左右,1选择左屏,2选择右屏***********************************************************/void WriteCommandLCD(unsigned char WCLCD , unsigned char BusyC,unsigned char select) {if(BusyC) ReadStatusLCD(select);//根据需要检测忙switch(select){case 1:{LCD_CSA=1;LCD_CSB=0;break;}//左case 2:{LCD_CSA=0;LCD_CSB=1;break;}//右default: break;}LCD_Data = WCLCD;LCD_RS = 0;LCD_RW = 0;LCD_E = 1;//_nop_(); //若晶振速度高,可在此作延时处理LCD_E = 0;}/************************************************************** **************** 功能:清显示RAM区(清屏)参数:select为驱动控制器选择1为左2为右*************************************************************** **************** */void clear_LCD(unsigned char select){unsigned char i,j;for(i=0;i<8;i++){ //8页,换页清零WriteCommandLCD( 0xb8|i,1 ,select);//页面地址设置,并分别写入左右模块中WriteCommandLCD( 0x40,1 ,select);//列地址设置,设置为0列,并分别写入左右三个模块中for(j=0;j<64;j++){ //页内清零WriteDataLCD( 0 ,select);}}}/************************************************************** *************** 功能:清LCD左右屏*************************************************************** **************/ void Clr_All_Lcd(void){clear_LCD(1);clear_LCD(2);}/************************************************************** **************** 功能:LCD初始化,分为左,右模块初始化参数:select为驱动控制器选择1为左2为右*************************************************************** **************** */void LcdReset(void){unsigned char i;for(i=0;i<5;i++){WriteCommandLCD( 0xc0,0 ,R);//设置显示起始行为第一行,并分别写入左右模块中,不检测忙标志WriteCommandLCD( 0xc0,0 ,L);//_nop_(); //若晶振速度高,可在此作延时处理}WriteCommandLCD( 0xc0,1 ,R);//设置显示起始行为第一行,并分别写入左右模块中,检测忙标志WriteCommandLCD( 0xc0,1 ,L);WriteCommandLCD( 0x3f,1 ,R);//开显示设置,并分别写入左右模块中WriteCommandLCD( 0x3f,1 ,L);clear_LCD(R);//清左屏clear_LCD(L);//清右屏}/************************************************************** **************** 功能:设置数据写入或读出的地址,通过页号和列数可以唯一确定一个地址参数:Column表示列号,Page表示页号*************************************************************** **************** */void set_XY(unsigned char Column,unsigned char Page){unsigned char x,y;unsigned char select;switch (Column&0x40) //完成左右屏的判断,根据列号完成区分,<64为左屏,>=64为右屏{case 0x00: {select = 1;ReadStatusLCD(select);break;}/*为左区*/case 0x40: {select = 2;ReadStatusLCD(select);break;}/*为右区*/}x = Column&0x3F|0x40; /* col.and.0x3f.or.Set Y Address*/ y = Page&0x07|0xB8; /* row.and.0x07.or.set Page */WriteCommandLCD( y,1 ,select);//设置页面地址WriteCommandLCD( x,1 ,select);//设置列地址}/************************************************************** **************** 功能:根据地址值(页数和列号),写入数据,即写入显示缓冲区,便可以显示在LCD屏上参数:Column表示列号,Page表示页号,dataW表示待写入的数据*************************************************************** **************** */void xy_Write(unsigned char Column,unsigned char Page,unsigned char dataW){set_XY(Column,Page);LCD_RW=0;LCD_RS=1;_nop_();//若晶振速度高,可在此作延时处理LCD_Data = dataW;// 送数据_nop_(); //若晶振速度高,可在此作延时处理LCD_E = 1;_nop_(); //若晶振速度高,可在此作延时处理LCD_E= 0; // 操作允许脉冲信号,下降沿写入}/************************************************************** **************** 功能:用于显示点阵参数:Column表示列号,Page表示页号,*************************************************************** **************** */void LcmPutDots(unsigned char Column,unsigned char Page, unsigned char DotByte ){unsigned char i;i=Column;for(;Page<8;Page++){for(;Column<128;Column++){xy_Write(Column,Page,DotByte);//DotByte = ~DotByte;}Column=i;}}/************************************************************** **************** 功能:在指定列,指定页显示待显示的点阵编码,用于显示16*16点阵码参数:Column表示列号,Page表示页号,puts待显示的点阵编码首指针*************************************************************** **************** */void whiteword(unsigned char Column,unsigned char Page, const unsigned char puts[][16] ){unsigned char i,j;for(i=0;i<2;i++)//此处的2为控制点阵行数,实际点阵行数为2*8=16行,此处的16(对应的点行数)应为8的倍数{for(j=0;j<16;j++)//此处控制每行显示的列数{xy_Write(Column+j,Page+i,puts[i][j]);}}}/****************************************************************************** 功能:在指定列,指定页显示待显示指定点阵的编码参数:Column表示列号,Page表示页号,C_num为显示点阵的行数(物理行8的倍数),V_num 为列(物理列)puts待显示的点阵编码首指针*************************************************************** **************** */void WhiteWord_Com(unsigned char Column,unsigned char Page,unsigned char C_num,unsigned char V_num, unsigned char * puts){unsigned char i,j;for(i=0;i<(C_num/8);i++)//此处的2为控制点阵行数,实际点阵行数为2*8=16行,此处的16(对应的点行数)应为8的倍数{for(j=0;j<="">{xy_Write(Column+j,Page+i,*(puts+i*V_num+j));//注意地址的变化规律}}}/************************************************************** **************** 功能:绘点参数:Column表示列号,Page表示页号,C_num为显示点阵的行数(物理行8的倍数),V_num 为列(物理列)puts待显示的点阵编码首指针*************************************************************** **************** */void Drawing_dot(unsigned char x,unsigned char y){unsigned char y_byte,x_bit,y_bit,reverse_y;//此处y_byte为page,y_bit为具体行号,x_bit 为行号unsigned char dot;reverse_y=63-y;x_bit=x;y_byte=reverse_y/8;y_bit=y%8;// for(;x_bit<128;x_bit++)if(y_bit==0) dot=0x80;if(y_bit==1) dot=0x40;if(y_bit==2) dot=0x20;if(y_bit==3) dot=0x10;if(y_bit==4) dot=0x08;if(y_bit==5) dot=0x04;if(y_bit==6) dot=0x02;if(y_bit==7) dot=0x01;xy_Write(x_bit,y_byte,dot);/* reverse_y=64-y;if(y_bit==7) y_byte=y_byte-1;y_bit=y%8;if(y_byte==(-1)) break;*/}/************************************************************** **************** 功能:绘垂直直线参数:x表示列号*************************************************************** **************** */void Drawing_line_vertical(unsigned char x){xy_Write(x,0,0xff);xy_Write(x,1,0xff);xy_Write(x,2,0xff);xy_Write(x,3,0xff);xy_Write(x,4,0xff);xy_Write(x,5,0xff);xy_Write(x,6,0xff);xy_Write(x,7,0xff);}主程序.c/************************************************************** **************** ****************12864液晶屏上显示"南京绝妙科技发展有限公司,025-******** 开发板欢迎使用","0~9",刷新后重显。
用51单片机做的万年历,显示用12864液晶
LCD12864.c#include "reg52.h"#include "intrins.h"#define uchar unsigned char#define uint unsigned int#define LCD_DB_PORT P0 //液晶DB0~DB7 #define LCD_START_ROW 0xc0 //起始行#define LCD_PAGE 0xb8 //页指令#define LCD_COL 0x40 //列指令//液晶引脚定义sbit LCD_DI=P2^0;sbit LCD_RW=P2^1;sbit LCD_E=P2^2;sbit LCD_CS1=P2^3;sbit LCD_CS2=P2^4;sbit LCD_RST=P2^5;bit Reverse_Display=0;//检查LCD是否忙bit LCD_Check_Busy(void){ LCD_DB_PORT=0xff;LCD_RW=1; _nop_(); LCD_DI=0;LCD_E=1; _nop_(); LCD_E=0;return(bit)(P0&0x80);}//向LCD发送命令void LCD_Write_Command(uchar c){ while(LCD_Check_Busy());LCD_DB_PORT=0xff; LCD_RW=0; _nop_(); LCD_DI=0;LCD_DB_PORT=c; LCD_E=1; _nop_(); LCD_E=0;}//向LCD发送数据void LCD_Write_Data(uchar d){ while(LCD_Check_Busy());LCD_DB_PORT=0xff;LCD_RW=0;_nop_();LCD_DI=1;//根据Reverse_Display决定是否反相显示if(!Reverse_Display)LCD_DB_PORT=d;else LCD_DB_PORT=~d;LCD_E=1;_nop_();LCD_E=0;}//初始化LCDvoid LCD_Initialize(void){ LCD_CS1=1;LCD_CS2=1;LCD_Write_Command(0x38);LCD_Write_Command(0x0f);LCD_Write_Command(0x01);LCD_Write_Command(0x06);LCD_Write_Command(LCD_START_ROW);}//通用显示函数//从第P页第L列开始显示W个字节数据,数据在r所指向的缓冲//每字节8位是垂直显示的,高位在下,低位在上//每个8*128的矩形区域为一页//整个LCD右由64*64的左半屏和64*64的右半屏构成void Common_Show(uchar P,uchar L,uchar W,uchar *r){ uchar i;if(L<64) //显示在左半屏或左右半屏{ LCD_CS1=1;LCD_CS2=0;LCD_Write_Command(LCD_PAGE+P);LCD_Write_Command(LCD_COL+L);if(L+W<64) //全部显示在左右半屏{ for(i=0;i<W;i++)LCD_Write_Data(r[i]);}else //如果越界则跨左右半屏显示{ for(i=0;i<64-L;i++)LCD_Write_Data(r[i]); //左半屏显示LCD_CS1=0;LCD_CS2=1; //右半屏显示LCD_Write_Command(LCD_PAGE+P);LCD_Write_Command(LCD_COL);for(i=64;i<W;i++)LCD_Write_Data(r[i]);}}else //全部显示在右半屏{ LCD_CS1=0;LCD_CS2=1;LCD_Write_Command(LCD_PAGE+P);LCD_Write_Command(LCD_COL+L-61);for(i=0;i<W;i++)LCD_Write_Data(r[i]);}}//显示8*16点阵字符void Display_A_Char_8X16(uchar P,uchar L,uchar *M) { Common_Show(P,L,8,M);Common_Show(P+1,L,8,M+8);}//显示一个16*16点阵汉字void Display_A_WORD(uchar P,uchar L,uchar *M) { Common_Show(P,L,16,M); //显示汉字上半部分Common_Show(P+1,L,16,M+16);}Main.c#include "reg52.h"#include "intrins.h"#include "string.h"#include "LCD_12864.c"#define uchar unsigned char#define uint unsigned int/*extern void LCD_Initialize(void);extern void Display_A_Char_8X16(uchar P,uchar L,uchar *M); extern void Display_A_WORD(uchar P,uchar L,uchar *M);//在调整日期时间时,用该位决定是否反白显示extern bit Reverse_Display=0;*/sbit SDA=P1^0; //DS1302数据线sbit CLK=P1^1; //DS1302时钟线sbit RST=P1^2; //DS1302复位线sbit k1=P3^4; //选择sbit k2=P3^5; //加sbit k3=P3^6; //减sbit k4=P3^7; //确定uchar tCount=0;//一年中每个月的天数,2月的天数由年份决定uchar MonthsDays[]={0,31,0,31,30,31,30,31,31,30,31,30,31};//所读取的日期时间uchar DateTime[7];//当前调整的时间对象:秒,分,时,日,月,年(0,1,2,3,4,6)//5对应星期,星期调节由年月日调整自动完成char Adjust_Index=-1;//水平与垂直偏移uchar H_Offset=10,V_Page_Offset=0;//年月日,星期,时分秒汉字点阵(16*16)------------------------------- uchar code DATE_TIME_WORDS[]={/*-- 文字: 年--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x20,0x18,0xC7,0x44,0x44,0x44,0x44,0xFC,0x44,0x44,0x44,0x44,0x 04,0x00,0x00,0x04,0x04,0x04,0x07,0x04,0x04,0x04,0x04,0xFF,0x04,0x04,0x04,0x04,0x 04,0x04,0x00,/*-- 文字: 月--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x00,0xFE,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0xFE,0x 00,0x00,0x00,0x80,0x40,0x30,0x0F,0x02,0x02,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x/*-- 文字: 日--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x00,0xFE,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0xFE,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0xFF,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xFF,0x00,0x 00,0x00,0x00,/*-- 文字: 星--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x00,0xBE,0x2A,0x2A,0x2A,0xEA,0x2A,0x2A,0x2A,0x3E,0x00, 0x00,0x00,0x00,0x00,0x44,0x42,0x49,0x49,0x49,0x49,0x7F,0x49,0x49,0x49,0x49,0x41,0x 40,0x00,0x00,/*-- 文字: 期--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x04,0xFF,0x24,0x24,0x24,0xFF,0x04,0x00,0xFE,0x22,0x22,0x22,0xF E,0x00,0x00,0x88,0x48,0x2F,0x09,0x09,0x19,0xAF,0x48,0x30,0x0F,0x02,0x42,0x82,0x 7F,0x00,0x00,/*-- 文字: 时--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0xFC,0x84,0x84,0x84,0xFC,0x00,0x10,0x10,0x10,0x10,0x10,0xFF,0x0x00,0x3F,0x10,0x10,0x10,0x3F,0x00,0x00,0x01,0x06,0x40,0x80,0x7F,0x0 0,0x00,0x00,/*-- 文字: 分--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x80,0x40,0x20,0x90,0x88,0x86,0x80,0x80,0x80,0x83,0x8C,0x10,0x20,0x 40,0x80,0x00,0x00,0x80,0x40,0x20,0x18,0x07,0x00,0x40,0x80,0x40,0x3F,0x00,0x00,0x 00,0x00,0x00,/*-- 文字: 秒--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x24,0x24,0xA4,0xFE,0x23,0x22,0x00,0xC0,0x38,0x00,0xFF,0x00,0x08,0x 10,0x60,0x00,0x08,0x06,0x01,0xFF,0x01,0x06,0x81,0x80,0x40,0x40,0x27,0x10,0x0C,0x 03,0x00,0x00,};//星期几的汉字点阵(16*16)----------------------------------uchar code WEEDDAY_WORDS[]={/*-- 文字: 日--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x00,0xFE,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0xFE,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0xFF,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xFF,0x00,0x 00,0x00,0x00,/*-- 文字: 一--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x 80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,/*-- 文字: 二--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x 00,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x 10,0x10,0x00,/*-- 文字: 三--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x04,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x 04,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x 20,0x20,0x00,/*-- 文字: 四--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0xFC,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x FC,0x00,0x00,0x00,0x7F,0x28,0x24,0x23,0x20,0x20,0x20,0x20,0x21,0x22,0x22,0x22,0x 7F,0x00,0x00,/*-- 文字: 五--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x02,0x42,0x42,0x42,0xC2,0x7E,0x42,0x42,0x42,0x42,0xC2,0x02,0x 02,0x00,0x00,0x40,0x40,0x40,0x40,0x78,0x47,0x40,0x40,0x40,0x40,0x40,0x7F,0x40,0x 40,0x40,0x00,/*-- 文字: 六--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x20,0x20,0x20,0x20,0x20,0x20,0x21,0x22,0x2C,0x20,0x20,0x20,0x20,0x 20,0x20,0x00,0x00,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x00,0x01,0x02,0x04,0x18,0x 60,0x00,0x00,};//半角数字点阵(8*16)---------------------------------------------------- uchar code DIGITS[]={/*-- 文字: 0 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,/*-- 文字: 1 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x 20,0x00,0x00,/*-- 文字: 2 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x 21,0x30,0x00,/*-- 文字: 3 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x 11,0x0E,0x00,/*-- 文字: 4 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x 3F,0x24,0x00,/*-- 文字: 5 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x 11,0x0E,0x00,/*-- 文字: 6 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x 11,0x0E,0x00,/*-- 文字: 7 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x 00,0x00,0x00,/*-- 文字: 8 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x 22,0x1C,0x00,/*-- 文字: 9 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x 11,0x0F,0x00,};//向DS1302写入一字节void Write_A_Byte_TO_DS1302(uchar x){ uchar i;for(i=0;i<8;i++){ SDA=x&1; CLK=1; CLK=0; x>>=1;}}//从DS1302读取一字节uchar Get_A_Byte_FROM_DS1302(void) { uchar i,b,t;for(i=0;i<8;i++){ b>>=1; t=SDA; b|=t<<7; CLK=1; CLK=0;}//BCD码转换return(b/16*10+b%16);}//从DS1302指定位置读数据uchar Read_Data(uchar addr){ uchar dat;RST=0; CLK=0; RST=1;Write_A_Byte_TO_DS1302(addr);dat=Get_A_Byte_FROM_DS1302();CLK=1; RST=0;return(dat);}//向DS1302某地址写入数据void Write_DS1302(uchar addr,uchar dat){ CLK=0; RST=1;Write_A_Byte_TO_DS1302(addr);Write_A_Byte_TO_DS1302(dat);CLK=0; RST=0;}//设置时间void SET_DS1302(void){ uchar i;Write_DS1302(0x8e,0x00);//秒分时日月年依次写入for(i=0;i<7;i++){ //秒的起始地址1000 0000(0x80)//后续依次是分,时,月,周,年,写入地址每次递增2Write_DS1302(0x80+2*i,(DateTime[i]/10<<4)|(DateTime[i]%10));}Write_DS1302(0x8e,0x80);}//读取当前日期时间void GetTime(void){ uchar i;for(i=0;i<7;i++){ DateTime[i]=Read_Data(0x81+2*i);}}//半断是否为闰年uchar isLeapYear(uint y){ return((y%4==0&&y%100!=0)||(y%400==0)); }//--------------------------------------------//求自2000.1.1开始的任何一天是星期几//函数没有通过,求出总天数后在求出星期几//因为求总天数可能会月出uint的范围//--------------------------------------------void RefreshWeekDay(void){ uint i,d,w=5; //已知1999.12.31是周五for(i=2000;i<2000+DateTime[6];i++){ d=isLeapYear(i)?366:365;w=(w+d)%7;}d=0;for(i=1;i<DateTime[4];i++)d+=MonthsDays[i];d+=DateTime[3];//保存星期,0~6表示星期日,星期一,二,、、、六,为了与DS1302的星期格式匹配,返回值需要加1DateTime[5]=(w+d)%7+1;}//年月日时分秒++/--void DateTime_Adjust(char x){ switch(Adjust_Index){ case 6: //年00-99if(x==1&&DateTime[6]<99)DateTime[6]++;if(x==-1&&DateTime[6]>0)DateTime[6]--;//获取2月天数MonthsDays[2]=isLeapYear(2000+DateTime[6])?29:28;//如果年份变化后当前月份的天数大于上限则设为上限if(DateTime[3]>MonthsDays[DateTime[4]])DateTime[3]=MonthsDays [DateTime[4]];RefreshWeekDay(); //刷新星期break;case 4: //月01-12if(x==1&&DateTime[4]<12)DateTime[4]++;if(x==-1&&DateTime[4]>1)DateTime[4]--;//获取2月份天数MonthsDays[2]=isLeapYear(2000+DateTime[6])?29:28;//如果月份变化后当前月份的天数大于上限则设为上限if(DateTime[3]>MonthsDays[DateTime[4]])DateTime[3]=MonthsDays [DateTime[4]];RefreshWeekDay(); //刷新星期break;case 3: //日00-28/29/30/31;调节之前首先根据年份得出该年中2月的天数MonthsDays[2]=isLeapYear(2000+DateTime[6])?29:28;//根据当前月份决定调节日期的上限if(x==1&&DateTime[3]<MonthsDays[DateTime[4]])DateTime[3]++;if(x==-1&&DateTime[3]>1)DateTime[3]--;RefreshWeekDay(); //刷新星期break;case 2: //时if(x==1&&DateTime[2]<23)DateTime[2]++;if(x==-1&&DateTime[3]>1)DateTime[2]--;break;case 1: //分if(x==1&&DateTime[1]<59)DateTime[1]++;if(x==-1&&DateTime[1]>1)DateTime[1]--;break;case 0: //秒if(x==1&&DateTime[0]<59)DateTime[0]++;if(x==-1&&DateTime[0]>1)DateTime[0]--;}}//定时器0每秒刷新LCD显示void T0_INT(void) interrupt 1{ TH0=-50000/256;TL0=-50000%256;if(++tCount!=2)return;tCount=0;if(Adjust_Index==-1)GetTime(); //如果未执行调整操作则正常读取当前时间//年后两位Reverse_Display=Adjust_Index==6; /*等同于{ if(Adjust_Index==6)Reverse_Display=1;else Reverse_Display=0; } */Display_A_Char_8X16(V_Page_Offset,16+H_Offset,DIGITS+DateTime [6]/10*16);Display_A_Char_8X16(V_Page_Offset,24+H_Offset,DIGITS+DateTime [6]%10*16);//月Reverse_Display=Adjust_Index==4;Display_A_Char_8X16(V_Page_Offset,48+H_Offset,DIGITS+DateTime [4]/10*16);Display_A_Char_8X16(V_Page_Offset,56+H_Offset,DIGITS+DateTime [4]%10*16);//日Reverse_Display=Adjust_Index==3;Display_A_Char_8X16(V_Page_Offset,80+H_Offset,DIGITS+DateTime [3]/10*16);Display_A_Char_8X16(V_Page_Offset,88+H_Offset,DIGITS+DateTime [3]%10*16);//星期Reverse_Display=Adjust_Index==5;Display_A_WORD(V_Page_Offset+2,96+H_Offset,WEEDDAY_WORDS +(DateTime[5]-1)*32);//时Reverse_Display=Adjust_Index==2;Display_A_Char_8X16(V_Page_Offset+5,16+H_Offset,DIGITS+DateTi me[2]/10*16);Display_A_Char_8X16(V_Page_Offset+5,24+H_Offset,DIGITS+DateTi me[2]%10*16);//分Reverse_Display=Adjust_Index==1;Display_A_Char_8X16(V_Page_Offset+5,48+H_Offset,DIGITS+DateTi me[1]/10*16);Display_A_Char_8X16(V_Page_Offset+5,56+H_Offset,DIGITS+DateTi me[1]%10*16);//秒Reverse_Display=Adjust_Index==0;Display_A_Char_8X16(V_Page_Offset+5,80+H_Offset,DIGITS+DateTi me[0]/10*16);Display_A_Char_8X16(V_Page_Offset+5,88+H_Offset,DIGITS+DateTi me[0]%10*16);}//键盘中断(INT0)void EX_INT0(void) interrupt 0{ if(k1==0) //选择调整对象{ if(Adjust_Index==-1||Adjust_Index==0)Adjust_Index=7;Adjust_Index--;if(Adjust_Index==5)Adjust_Index=4; //跳过对星期的调整}else if(k2==0)DateTime_Adjust(1); //加else if(k3==0)DateTime_Adjust(-1); //减else if(k4==0) //确定{ SET_DS1302(); //将调整后的时间写入DS1302Adjust_Index=-1; //操作索引重设为-1,时间继续正常显示}}//主程序void main(){ //液晶初始化LCD_Initialize();//显示年的固定前两位Display_A_Char_8X16(V_Page_Offset,0+H_Offset,DIGITS+2*16);Display_A_Char_8X16(V_Page_Offset,8+H_Offset,DIGITS);//显示固定汉字:年月日,星期,时分秒Display_A_WORD(V_Page_Offset,32+H_Offset,DATE_TIME_WORDS+ 0*32);Display_A_WORD(V_Page_Offset,64+H_Offset,DATE_TIME_WORDS+ 1*32);Display_A_WORD(V_Page_Offset,96+H_Offset,DATE_TIME_WORDS+ 2*32);Display_A_WORD(V_Page_Offset+2,64+H_Offset,DATE_TIME_WORD S+3*32);Display_A_WORD(V_Page_Offset+2,80+H_Offset,DATE_TIME_WORD S+4*32);Display_A_WORD(V_Page_Offset+5,32+H_Offset,DATE_TIME_WORD S+5*32);Display_A_WORD(V_Page_Offset+5,64+H_Offset,DATE_TIME_WORD S+6*32);Display_A_WORD(V_Page_Offset+5,96+H_Offset,DATE_TIME_WORD S+7*32);//允许INT0,T0中断IE=0x83;IP=0x01;IT0=0x01;TH0=-50000/256;TL0=-50000%256;TR0=1;while(1);}。
浅析MCS-51单片机的液晶12864显示设计
浅析 MCS-51单片机的液晶 12864 显示设计【摘要】:基于MCS-51单片机的液晶显示的设计,利用单片机的I/O口外接液晶,通过软件模拟的方法,从而使得液晶12864显示所需的字符。
【关键词】单片机;液晶12864;显示1、引言单片机是一种可通过编程控制的微处理器,单片机芯片自身不能单独运用于某项工程或者产品上,它必须要依靠外围数字器件或模拟器件的协调才可以发挥其自身的强大功能,本文介绍如何点亮液晶,实现显示字符的效果。
2、硬件组成液晶12864显示系统实际是由51单片机最小系统、液晶12864构成,如下图1所示。
图1 电路图3、程序设计#include#define uchar unsigned char#define uint unsigned intSbit LCD_ rs=P2^0; //4脚sbit LCD_ rw=P2^1; //5脚sbit LCD_ e=P2^2; //6脚#define LCD_PORT P0 //数据端口void write_LCD_ cmd_add(uchar cmd) //向LCD写入地址或地址{ uint t=1000;LCD_ e=0; //此时不会理rw 和rsLCD_ rs=0;//表示写命令LCD_ rw=0;//表示写入LCDLCD_PORT=cmd;LCD_ e=1;//LCD开始接受命令while(t--);LCD_ e=0; //结束}void LCD_ write_data(uchar da) //写入显示数据{ uint t=500;LCD_ e=0; //此时不会理rw 和rsLCD_ rs=1;//表示数据LCD_ rw=0;//表示写入LCDLCD_PORT=da;LCD_ e=1;//LCD开始接受数据while(t--);LCD_ e=0; //结束}void LCD_drive(bit m,uchar d) //写命令还是数据{ if(m==0)LCD_ write_cmd_add(d);elseLCD_ write_data(d);}void LCD_init(){ uint t=5000;LCD_drive(0,0x0f);LCD_drive(0,0x01);//清屏while(t--);}void show_word(char add,uchar *p)//显示汉字{LCD_drive(0,add);//显示地址LCD_drive(1,*p++);//数据LCD_drive(1,*p);//显示地址}void main(){ LCD_init();show_word(0x90,"你");show_word(0x91,"很");show_word(0x92,"棒");while(1){}}4、结束当上述程序编写好之后,我们需要使用编译软件对其编译,得到单片机能识别的二进制代码,然后再用编程器将二进制代码烧写到单片机中,就能看到液晶12864的显示,第二排依次显示“你很棒”。
无字库12864液晶模块应用
无字库12864液晶模块应用
图1
在上次介绍的日历钟的基础上扩展一下:让它具备检测大气温度和湿度的
功能,一天24 小时不间断运行并定时检测,于是,日历钟就摇身一变成为一
个小小温湿度计啦。
虽然气象要素很多,不过我们最常用的就是气温和湿度。
一个是冷热程度,一个是环境空气中含水蒸气的多少。
一般家用温度计很常见,湿度计就比较少,以前有一种干湿球温度计,但是用起来比较麻烦,准确度也不高。
现在应用电子技术我们就可以做一个可以同时显示温度、湿度、时间的小仪器,放在家里以便随时监测我们的小环境。
它的特点如下:
1.在单片机ATMega8L-8PU(以下简称M8)和日历钟电路DS1302 的基础上,使用一个在工厂经过精密校准的数字式温度、湿度传感器AM2301 作为探头;
2.当24 小时连续工作时,纵然工作电流仅为几毫安,也不宜使用纽扣电池
供电。
这次选用可充电的3.6V 聚合物锂电池,使它的放置地点可以不受电源
限制,可以在室内,也可以在不受阳光直射和雨水接触的室外;
3.具有文字和图形界面,可以显示温度和湿度数值,以及12 小时内的湿度
变化记录曲线,为什么是湿度曲线呢?因为气温的变化规律一般比较稳定,湿度就不一样了,我们可以从湿度变化趋势估计一下未来的晴雨可能,这比看燕。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
/* 选择屏幕来清屏 */
菜鸟学习 51 单片机
while(1)世界
void Lcd12864Clear(uint8 selet)
{
uint8 i,j;
Lcd12864SeletScreen(selet); //选择屏,分左屏和又屏,这个函数在程序中有
for(i = 0;i < 8 ;i++)
二.写入地址
void Lcd12864Point(uint8 page,uint8 x,uint8 y)
{
Lcd12864Write(CMD,0xb8 + page);
//确定页
Lcd12864Write(CMD,0xC0 + x);
//设定起始行
Lcd12864Write(CMD,0x40 + y);
菜鸟学习 51 单片机
while(1)世界
现在开始讲解如何使用,看这篇讲解前,请先到网盘去下载本教 程的仿真图和程序,结合起来更容易明白。
上图是仿真的结果。 在仿真软件中找出的 12864 液晶是没有字库的,对于仿真软件中 液晶的控制和平常的有点不同。一块液晶是由两块 64×64 的液晶显 示模块组合而成。下面是各管脚的介绍。
//有 8 页,循环 8 次
{
Lcd12864Point(i,0,0); //这个就是上面讲到的函数,确定位置
for(j = 0 ;j < 64;j++) //每一块液晶显示模块有 64 列
{
Lcd12864Write(DAT,0x00); //写入 0x00 来清屏
}
}
}
具体的使用如下:初始化函数中调用了清全屏 Lcd12864Clear(3); //清全屏
61 62 63
DB0
|
PAGE0
X=0
DB7
DB0
菜鸟学习 51 单片机
|
PAGE1
DB7 ………………
DB0
|
PAGE6
DB7
DB0
|
PAGE7
DB7
while(1)世界
X=1 ……
X=6
X=7
在写入数据的时候就需要先设定页数和列数。在程序中就有专门用来 指定位置的函数:
/* 定写入的地址,选择页,起始行和列 */ void Lcd12864Point(uint8 page,uint8 x,uint8 y) {
菜鸟学习 51 单片机
while(1)世界
至于写命令,写数据,读数据的函数基本上和 1602 液晶是一样
的。大家可以对着程序看。都有注释。控制液晶就需要知道几个重要
的命令和液晶的地址。
(1) 显示开/关设置 CODE:R/W RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
L L L L H H H H H H/L
功能:设置屏幕显示开/关。
DB0=H,开显示;DB0=L,关显示。不影响显示 RAM(DD RAM)中的内容。
(2) 设置显示起始行
CODE:R/W RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
LL HH
行地址(0~63)
功能:执行该命令后,所设置的行将显示在屏幕的第一行。显示起始行是由
Z 地址计数器控制的,该命令自动将 A0-A5 位地址送入 Z 地址计数器,起始地
址可以是 0-63 范围内任意一行。Z 地址计数器具有循环计数功能,用于显示行
扫描同步,当扫描完一行后自动加一。
(3) 设置页地址 CODE:R/W RS DB7 DB6 DB5 DB4 DB3
LL HL HHH
DB2 DB1 DB0 页地址(0~7)
Lcd12864Write(CMD,0xb8 + page); Lcd12864Write(CMD,0xC0 + x); Lcd12864Write(CMD,0x40 + y); }
入口函数就是设定的页数,起始行数,列数。后面的 0xb8 是页的起 始地址,0xc0 是行的起始地址,0x40 是列的起始地址。(此处的行是 起始行)。
功能:执行本指令后,下面的读写操作将在指定页内,直到重新设置。
地址就是 DD RAM 的行地址,页地址存储在 X 地址计数器中,
DB2-DB0 可表示 8 页,读写数据对页地址没有影响,除本指令可改
变页地址外,复位信号(RST)可把页地址计数器内容清零。DDRAM
地址映像表如下:
Y 地址
0
12
………
菜鸟学习 51 单片机
while(1)世界
菜鸟学习 51 单片机
----12864 液晶(无字库)
《菜鸟学习 51 单片机》由 while(1)世界推出的非常简单的 51 单片机教程。帮助刚接触单片机的童鞋快速入门。
这一讲是由 Admin 编写!读者有什么问题的可以在 while(1) 世界的 51 版块发帖提问!童鞋可以在 while1 世界网盘下载本教程的 仿真图和程序。这次的程序采用的是模块化编程写的,如果不懂模块 化的,欢迎下载菜鸟学习 51 单片机之模块化编程学习。
{
Lcd12864Write(DAT,*p);
p++;
}
Lcd12864Point(page + 1,x,y);
//由于是 8×16,换页再写入 8 个数据
for(number = 0;number < 8;number++)
{
Lcd12864Write(DAT,*p);
p++;
}
//对讲解还有疑问的欢迎到论坛的 51 版块提问。
//设定列
}
三.取字模
字模软件的设定如下图所示:
菜鸟学习 51 单片机
while(1)世界
四.写入数据(字模是 8*16,按照下面的方式写入数据)
Lcd12864Point(page,x,y);
//设定地址
for(number = 0;number < 8;number++) //写入 8 个字模数据