无字库LCD12864(无时钟芯片显示时间)
基于无字库12864液晶模块的日历钟设计制作
基于无字库12864液晶模块的日历钟设计制作时间:2010-10-18 21:07:14 来源:作者:本文我们要利用无字库12864液晶模块来自制一个小小日历钟,最图终效果图见图1。
这个小小日历钟有什么特点呢?1、电路简单,使用元件少,容易制作,核心就是单片机ATMega8L和日历钟忡1302。
2、全部使用低压元件,3V电压就可以工作。
3,使用自编的小字模和图形界面使得显示具有特色:在文字界面可以清晰地读出当前的日期和时间,而且加入一个小动画使显示更加生动,在图形界面使用模拟刻度和指针动态指示当前时间,两个界面柙按键切换。
图2电路原理4、电源制作在独立的小电路板上,调试程序时插入使用USB供电的3.3V稳压电源,完毕后可以取下,插上开关,使用电池供电。
5、不用背光时耗电很小(全机约3mA),可以使用圆片锂电池CR2O32供电。
日历钟安装在一块50mm x50mm小万用板上。
外形见图1。
电路原理电原理图见图2,液晶型号如前述,单片机就是AVR的ATMega8L-8PU(以下简称M8),可以在低电压下工作,M8 的PD口控制液晶,主要就是控制串行写入显示数据。
DS13O2(以下简称1302)是常用的日历时钟芯片,32768Hz晶体B是它的振荡源。
在它内部有10个命令寄存器用来存储日期、时间的数值并控制芯片工作,M8通过PB0PB1、PB2控制1302的RST、SCLK、I/O:RST为高时才能读写1302,读写都是让数据在I/O串行传送,当SCLK上升沿时写入1位地址或数据,写入1位地址或数据。
写入地址后每当SCLK 下降沿时则读出数据。
读写都是从最低位开始,受SCLK时钟同步。
接通电源后它必须通过单片机程序启动计时,只要有电源或者各用电源存在,它就能一直工作下去,和单片机是否工作无关。
连接在M8的PC口的4个轻触按键,S1,S2,S3用于调校时问:分别为确认修改、移动光标,修改数值;S4用于界面切换。
LCD12864做的数字钟(无数字芯片)+按键
#include<reg52.h>#include<intrins.h>//#include<stdlib.h> //rand();#define uint unsigned int#define uchar unsigned char#define LCD_data P0;uchar code table[]="2000年00月00日";uchar code time[]="时间00: 00: 00";uchar code xi1[]="星期一mo";uchar code xi2[]="星期二tu";uchar code xi3[]="星期三we";uchar code xi4[]="星期四th";uchar code xi5[]="星期五fr";uchar code xi6[]="星期六sa";uchar code xi7[]="星期天su";sbit LCD_PSB=P2^3;sbit LCD_RS=P2^0;sbit LCD_RW=P2^1;sbit LCD_EN=P2^2;sbit k1=P1^0;sbit k2=P1^1;sbit k3=P1^2;sbit k4=P1^3;uint i,shi,fen,miao,nian,yue,ri,count,num,x;void delay_1ms(uint x)/*******延时程序**********/ {uint i,j;for(j=0;j<x;j++)for(i=0;i<110;i++);}void write_cmd(uchar cmd)/*****写命令*******/ {LCD_RS=0;LCD_RW=0;LCD_EN=0;P0=cmd;delay_1ms(5);LCD_EN = 1;delay_1ms(5);LCD_EN= 0;}void write_dat(uchar dat) /******写数据*****/LCD_RS = 1;LCD_RW= 0;LCD_EN= 0;P0=dat;delay_1ms(5);LCD_EN= 1;delay_1ms(5);LCD_EN= 0;}void lcd_pos(uchar X,uchar Y) /*****光标显示位置******/{uchar pos;if(X==0){X=0x80;}else if(X==1){X=0x90;}else if(X==2){X=0x88;}else if(X==3){X=0x98;}pos= X+Y;write_cmd(pos);}void writesfm(uchar add,uchar dat) /*********显示时间程序*******/ {uchar s,g;s=dat/10;g=dat%10;lcd_pos(2,0+add);write_dat(0x30+s);write_dat(0x30+g);}void writenyr(uchar add,uchar dat)/*******显示**年**月**日****/ {uchar s,g;s=dat/10;g=dat%10;lcd_pos(0,0+add);write_dat(0x30+s);write_dat(0x30+g);}/*********** 星期显示******************/void xi(uchar a)if(a==1){lcd_pos(1,0);for(i=0;i<10;i++) {write_dat(xi1[i]); delay_1ms(5); }}if(a==2){lcd_pos(1,0);for(i=0;i<10;i++) {write_dat(xi2[i]); delay_1ms(5); }}if(a==3){lcd_pos(1,0);for(i=0;i<10;i++) {write_dat(xi3[i]); delay_1ms(5);}}if(a==4){lcd_pos(1,0);for(i=0;i<10;i++) {write_dat(xi4[i]); delay_1ms(5); }}if(a==5){lcd_pos(1,0);for(i=0;i<10;i++) {write_dat(xi5[i]); delay_1ms(5);}}if(a==6){lcd_pos(1,0);for(i=0;i<3;i++){write_dat(xi6[i]);delay_1ms(5);}}if(a==7){lcd_pos(1,0);for(i=0;i<10;i++){write_dat(xi7[i]);delay_1ms(5);}}}/*********************按键*****************/ void key(){if(k1==0){ delay_1ms(10);if(k1==0){num++;while(!k1);if(num==1){ write_cmd(0x0f);lcd_pos(2,6);TR0=0;}if(num==2){lcd_pos(2,4);}if(num==3){lcd_pos(2,2);}if(num==4){lcd_pos(0,5);}if(num==5){lcd_pos(0,3);}if(num==6){lcd_pos(0,1);}if(num==7){lcd_pos(1,3);}if(num==8){num=0;write_cmd(0x0c);TR0=1;}}}if(k2==0){delay_1ms(10);if(k2==0){while(!k2);if(num==1){miao++;if(miao==60){miao=0;}writesfm(6,miao);lcd_pos(2,6);}if(num==2){fen++;if(fen==60){fen=0;}writesfm(4,fen); lcd_pos(2,4);}if(num==3) {shi++;if(shi==24) {shi=0;}writesfm(2,shi); lcd_pos(2,2);}if(num==4) {ri++;if(ri==30){ri=0;}writenyr(5,ri); lcd_pos(0,5);}if(num==5) {yue++;if(yue==13) {yue=1;}writenyr(3,yue); lcd_pos(0,3);}if(num==6) {nian++;if(nian==100) {nian=0;}writenyr(1,nian);lcd_pos(0,1);}if(num==7){x++;xi(x);if(x==7){x=0;}}}}if(k3==0){delay_1ms(10);if(k3==0){while(!k3);if(num==1){miao--;if(miao==-1){miao=59;}writesfm(6,miao);lcd_pos(2,6);}if(num==2){fen--;if(fen==-1){fen=59;}writesfm(4,fen);lcd_pos(2,4);}if(num==3){shi--;if(shi==-1){shi=23;}writesfm(2,shi); lcd_pos(2,2);}if(num==4) {ri--;if(ri==-1){ri=30;}writenyr(5,ri); lcd_pos(0,5);}if(num==5) {yue--;if(yue==-1) {yue=12;}writenyr(3,yue); lcd_pos(0,3);}if(num==6) {nian--;if(nian==-1) {nian=99;}writenyr(1,nian); lcd_pos(0,1);}if(num==7) {x--;xi(x);if(x==1){x=8;}}}}}/*********************************************/void lcd_init() /********初始化********/{LCD_PSB=1;write_cmd(0x30);delay_1ms(1);write_cmd(0x0c);delay_1ms(1);write_cmd(0x01);delay_1ms(1);lcd_pos(0,0);for(i=0;i<13;i++){write_dat(table[i]);delay_1ms(1);}lcd_pos(1,0);for(i=0;i<10;i++){write_dat(xi7[i]);delay_1ms(1);}lcd_pos(2,0);for(i=0;i<14;i++){write_dat(time[i]);delay_1ms(1);}}void main() /********主函数*******/{lcd_init();TMOD=0x01;TH0=(65536-50000)/256;TL0=(65536-50000)%256;EA=1;ET0=1;TR0=1;while(1){key();if(count==20){count=0;miao++;if(miao==60){miao=0;fen++;if(fen==60){fen=0;shi++;if(shi==24){shi=0;ri++;x++;xi(x);if(x==7){x=0;}if(ri==31){ri=0;yue++;if(yue==13){yue=0;nian++;if(nian==100){nian=0;}writenyr(1,nian);}writenyr(3,yue);}writenyr(5,ri);}writesfm(2,shi);}writesfm(4,fen);}writesfm(6,miao);}}}void t()interrupt 1/********中断子函数********/ {TH0=(65536-50000)/256;TL0=(65536-50000)%256;count++;}。
AVR事无巨细系列七,LCD12864
事无巨细,LCD12864上次写了1602的使用,这次来写写LCD12864。
作为绝大多数单片机学习板的液晶显示模块之一,LCD12864功能要比LCD1602要强悍许多。
仅仅是1602的两行英文字母,数字和各种符号,严格来说勉强能显示几个中文,是无法满足我们的需求的。
当需要显示一些稍微复杂的图形的时候,12864的用处就显现出来了。
下面是两个正在工作的LCD12864:跟1602一样,各种型号的LCD12864在价格,性能,效率上也都是大同小异。
据我所知,市场上全新的12864价格在50到80不等,感觉有点贵。
不过,如果你要买的话,最好了解清楚它是不是带字库的。
什么是字库呢?就是在12864里的CGROM 存储器里存放有可调用显示的绝大部分的中文和各种符号。
这和我们调用GCC-AVR 的各种头文件里的子函数有点类似:如果没有这个头文件,那么你只能自己去编写;同样如果12864没有字库,你也需要自己去编一个字库,只是方式上是通过图形取模软件来转换实现的。
建议对自己实力不太自信的朋友购买带字库的LCD12864。
LCD12864,即像素为128*64的显示液晶。
它的每一行横向一共有128个可显示点,每一列纵向有64个,这些“点”其实也都是一个个发光二极管。
它可以在一个16*16的点阵区域上显示一个中文;也可以在一个8*16的点阵区域显示一个非中文字符,一般称为半宽字体。
即一个中文字所占显示面积是一个非中文字符的两倍。
LCD12864其实还有个叫法叫12864图形点阵,看出关键了么?对了,点阵二字。
归根结底,它是一个点阵。
既然是点阵,那么它的工作原理就和我们以前接触的LED 点阵类似。
B b s .C e p a r k .c o m即在要点亮的“点”上赋予正向压降即可。
理解这点,对使用12864的图形显示功能有基础作用。
关于LCD12864的引脚结构和功能,并非全部的LCD12864引脚都是一样的。
LCD12864显示实时时钟例程可运行
DS1302是美国DALLAS公司推出的一种高性能、低功耗的实时时钟芯片,附加31字节静态RAM,采用SPI三线接口与CPU进行同步通信,并可采用突发方式一次传送多个字节的时钟信号和RAM数据。
实时时钟可提供秒、分、时、日、星期、月和年,一个月小与31天时可以自动调整,且具有闰年补偿功能。
下面是一段12864液晶显示实时时钟的程序:/****************************************************************************** *********时间:2012.11.30晶振:11.0592MHz芯片:STC89C52RC功能描述:在12864上显示年、月、日、星期、时、分和秒等时间信息******************************************************************************* ********/#include<reg52.h>#define uchar unsigned charsbit CLK=P1^4; //DS1302引脚定义sbit IO=P1^5;sbit CE=P1^6;sbit ACC0=ACC^0;sbit ACC7=ACC^7;sbit RS=P2^4; //12864引脚定义数据口为P0sbit RW=P2^5;sbit EN=P2^6;sbit PSB=P2^1;sbit RET=P2^3;void Input_1byte(uchar TD) //DS1302输入一字节数据{uchar i;ACC=TD;for(i=8;i>0;i--){IO=ACC0;CLK=1;CLK=0;ACC=ACC>>1;}}uchar Output_1byte(void) //DS1302输出一字节数据{uchar i;for(i=8;i>0;i--){ACC=ACC>>1;ACC7=IO;CLK=1;CLK=0;}return(ACC);}void Write_DS1302(uchar add,uchar dat)//向DS1302写{CE=0;CLK=0;CE=1;Input_1byte(add);Input_1byte(dat);CE=0;}uchar Read_DS1302(uchar add) //从DS1302读{uchar inf; //信息临时存储变量CE=0;CLK=0;CE=1;Input_1byte(add);inf=Output_1byte();CE=0;return(inf);}/**********************DS1302初始化*****************************/void init_1302(){if(Read_DS1302(0xd1)==0x55) //判断内存单元的内容,是否进行初始化 {return;}else{Write_DS1302(0x8e,0x00); //关闭写保护Write_DS1302(0x90,0x00); //电池充电设置Write_DS1302(0x80,0x00); //秒Write_DS1302(0x82,0x54); //分Write_DS1302(0x84,0x20); //时Write_DS1302(0x86,0x30); //日Write_DS1302(0x88,0x11); //月Write_DS1302(0x8a,0x05); //星期Write_DS1302(0x8c,0x12); //年Write_DS1302(0xd0,0x55); //写RAMWrite_DS1302(0x8e,0x80); //打开写保护}}/**********************延时函数*****************************/ void DelayUs2x(unsigned char t){while(--t);}void DelayMs(unsigned char t){while(t--){//大致延时1mSDelayUs2x(245);DelayUs2x(245);}}/**********************12864判忙*****************************/ void check_busy(){RS=0;RW=1;EN=1;while((P0&0x80)==0x80);EN=0;}/**********************12864写指令*****************************/ void write_com(uchar com){check_busy();RS=0;RW=0;EN=1;P0=com;DelayUs2x(250);EN=0;DelayUs2x(250);}/**********************12864写数据*****************************/void write_data(uchar dat){check_busy();RS=1;RW=0;EN=1;P0=dat;DelayUs2x(250);EN=0;DelayUs2x(250);}/**********************12864初始化函数*****************************/void init(){DelayMs(40); //大于40MS的延时程序PSB=1; //设置为8BIT并口工作模式DelayMs(1); //延时RET=0; //复位DelayMs(1); //延时RET=1; //复位置高DelayMs(200);write_com(0x30); //选择基本指令集DelayUs2x(250); //延时大于100uswrite_com(0x30); //选择8bit数据流DelayUs2x(200); //延时大于37uswrite_com(0x0c); //开显示(无游标、不反白)DelayUs2x(250); //延时大于100uswrite_com(0x01); //清除显示,并且设定地址指针为00HDelayMs(200); //延时大于10mswrite_com(0x06); //指定在资料的读取及写入时,设定游标的移动方向及指定显示的移位,光标从右向左加1位移动DelayUs2x(250); //延时大于100us}/**********************清屏*****************************/void clrscreen(){write_com(0x01);DelayMs(15);}/*********************************************************主函数********************************************************/void main(){uchar sec,sec1,sec2;uchar min,min1,min2;uchar hour,hour1,hour2;uchar date,date1,date2;uchar mon,mon1,mon2;uchar day;uchar year,year1,year2;uchar table1[]="年月日时分秒星期温度摄氏"; //长度24uchar table2[]={0XD2,0XBB, 0XB6,0XFE, 0XC8,0XFD, 0XCB,0XC4, 0XCE,0XE5, 0XCE,0XF9, 0XC8,0XD5}; //长度14 uchar table3[]="0123456789"; //长度10init(); //液晶初始化clrscreen();DelayMs(200);init_1302(); //1302初始化只初始化一下就可以需要下载两次DelayMs(50);write_com(0x80); //显示20write_data('2');write_data('0');write_com(0x82); //显示年write_data(table1[0]);write_data(table1[1]);write_com(0x84); //显示月write_data(table1[2]);write_data(table1[3]);write_com(0x86); //显示日write_data(table1[4]);write_data(table1[5]);write_com(0x91); //显示时write_data(table1[6]);write_data(table1[7]);write_com(0x93); //显示分write_data(table1[8]);write_data(table1[9]);write_com(0x95); //显示秒write_data(table1[10]);write_data(table1[11]);write_com(0x88); //显示星期write_data(table1[12]);write_data(table1[13]);write_data(table1[14]);write_data(table1[15]);while(1){sec=Read_DS1302(0x81); ////读秒sec1=sec&0x0f; //个位sec2=sec>>4; //十位min=Read_DS1302(0x83); ////读分min1=min&0x0f; //个位min2=min>>4; //十位hour=Read_DS1302(0x85); ////读时hour1=hour&0x0f; //个位hour2=hour>>4; //十位date=Read_DS1302(0x87); ////读日date1=date&0x0f; //个位date2=date>>4; //十位mon=Read_DS1302(0x89); ////读月mon1=mon&0x0f; //个位mon2=mon>>4; //十位year=Read_DS1302(0x8d); ////读年year1=year&0x0f; //个位year2=year>>4; //十位day=Read_DS1302(0x8b); ////读星期write_com(0x94); //送显示内容write_data(table3[sec2]); //秒write_data(table3[sec1]);write_com(0x92);write_data(table3[min2]); //分write_data(table3[min1]);write_com(0x90);write_data(table3[hour2]); //时write_data(table3[hour1]);write_com(0x85);write_data(table3[date2]); //日write_data(table3[date1]);write_com(0x83);write_data(table3[mon2]); //月write_data(table3[mon1]);write_com(0x81);write_data(table3[year2]); //年write_data(table3[year1]);write_com(0x8a);write_data(table2[2*day-2]); //星期write_data(table2[2*day-1]);}}(注:范文素材和资料部分来自网络,供参考。
LCD12864(概念)
LCD12864(概念)LCD12864(控制芯片ST7920)128×64点阵液晶显示屏有三种控制器,分别是KS0107(KS0108)、T6963C和ST7920,三种控制器主要区别是:KS0107(KS0108)不带任何字库、T6963C带ASCII码,ST7920带国标二级字库(8千多个汉字)。
如果控制芯片为st7920。
带字库。
通讯方式:串行、并口可选;无需片选信号。
以下是需要了解的LCD12864液晶的概念:做液晶显示时DDRAM,CGROM,CGRAM,GDRAM的概念。
1、DDRAM是与显示屏对应的,DDRAM的容量比显示屏大很多,在做滚动屏或者翻页,页面切换时是有用的!!可以先把数据写到RAM里,一个命令切换就OK了。
2、CGROM是内部字符发生器。
存了一些预先设好的点阵。
当我们再DDRAM中输入某字符的代码时,它会自动显示其中的字符信息。
3、CGRAM用来给用户可以自定义所需的文字或符号,应该是写到RAM里就跟CGROM 一样用了。
CGRAM是用户自建字模区,有时ascii码表不能满足个人对字符的要求,则需要在这里写入字模。
字模的方式和CGRAM中的一样。
4、绘图RAM(GDRAM)绘图显示RAM 提供64×32 个位元组的记忆空间,最多可以控制256×64 点的二维绘图缓冲空间,在更改绘图RAM 时,先连续写入水平(0x80~0x87)与垂直(0x80~0x9f)的坐标值,再写入两个8 位元的资料到绘图RAM,而地址计数器(AC)会自动加一;在写入绘图RAM 的期间,绘图显示必须关闭,整个写入绘图RAM 的步骤如下:1、关闭绘图显示功能。
2、先将垂直的坐标(Y)写入绘图RAM 地址;3、再将水平的位元组坐标(X)写入绘图RAM 地址;4、将D15——D8 写入到RAM 中;5、将D7——D0 写入到RAM 中;6、打开绘图显示功能。
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液晶屏滚动显示程序
无字库12864液晶屏转动显示程序[转]#include<reg52.h>#include<intrins.h>#include<absacc.h>#defineLcd_BusP0//MCUP0<------>LCM#defineDisp_On0x3 f//#defineDisp_Off0x3 e//#defineCol_Add0x40 //#definePage_Add0xb8 //#defineStart_Line0x c0//开显示关显示列地点页地点开端页sbitcs1=P2^3;//Masterchipenablesbitcs2=P2^4;//SlavechipenablesbitEnable=P2^2;//modeEnablesinglesbitDi=P2^0;//DataorInstrumentSelectsbitRW=P2^1;//WriteorReadsbitLcd_Rst=P2^5;//Lcmreset/*****************************字模,此字体下对应的点阵为:宽x高=16x16*****************************/unsignedcharcodeChinese_character[][32]={{0x02,0xF2,0x12,0x12,0x12,0xFE,0x12,0x12,0x12,0xFE,0x12,0x12,0x12,0xF2,0x02,0x00, 0x00,0x7F,0x28,0x24,0x22,0x21,0x20,0x20,0x20,0x21,0x22,0x22,0x22,0x7F,0x00,0x00},/*" 西",0*/{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*/{0x00,0x42,0x62,0x5A,0xC6,0x10,0x54,0x54,0x54,0xFF,0x54,0x54,0x7C,0x10,0x10,0x0 0,0x40,0x23,0x14,0x08,0x17,0x28,0x29,0x49,0x49,0x7F,0x49,0x49,0x49,0x49,0x40,0x00},/*" 建",2*/{0x10,0x48,0x47,0xCC,0x54,0x44,0x14,0xE8,0x27,0x24,0x2C,0xF4,0x04,0x04,0x04,0x0 0,0x10,0x30,0x10,0x0F,0x88,0x48,0x30,0x0F,0x01,0x06,0x00,0x3F,0x40,0x40,0x70,0x00},/*" 筑",3*/{0x10,0x12,0x92,0x72,0xFE,0x51,0x91,0x00,0x22,0xCC,0x00,0x00,0xFF,0x00,0x00,0x00,0x04,0x02,0x01,0x00,0xFF,0x00,0x04,0x04,0x04,0x02,0x02,0x02,0xFF,0x01,0x01,0x00},/*" 科",4*/{0x08,0x08,0x88,0xFF,0x48,0x28,0x00,0xC8,0x48,0x48,0x7F,0x48,0xC8,0x48,0x08,0x0 0,0x01,0x41,0x80,0x7F,0x00,0x40,0x40,0x20,0x13,0x0C,0x0C,0x12,0x21,0x60,0x20,0x00},/*" 技",5*/{0x20,0x20,0x20,0x20,0x20,0x20,0xA0,0x7F,0xA0,0x20,0x20,0x20,0x20,0x20,0x20,0x0 0,0x00,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x01,0x06,0x08,0x30,0x60,0xC0,0x40,0x00},/*" 大",6*/{0x40,0x30,0x10,0x12,0x5C,0x54,0x50,0x51,0x5E,0xD4,0x50,0x18,0x57,0x32,0x10,0x0 0,0x00,0x02,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x02,0x02,0x02,0x02,0x02,0x02,0x00},/*" 学",4*/{0x00,0x02,0x1C,0xE8,0x00,0x40,0x60,0x58,0x47,0x22,0x20,0x28,0x30,0xE0,0x40,0x0 0,0x02,0x02,0x7F,0x00,0x00,0x00,0x7F,0x21,0x21,0x21,0x21,0x21,0x7F,0x00,0x00,0x00},/*" 冶",0*/{0x40,0x40,0x20,0x20,0x50,0x48,0x44,0xC3,0x44,0x48,0x50,0x50,0x20,0x60,0x20,0x0 0,0x40,0x40,0x42,0x42,0x4A,0x72,0x42,0x7F,0x42,0x62,0x5A,0x42,0x42,0x40,0x40,0x00},/*" 金",1*/{0x00,0x00,0x02,0x02,0x02,0x02,0x02,0xFE,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x0 0,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00},/*" 工",2*/{0x10,0x12,0xD2,0xFE,0x91,0x11,0x80,0xBF,0xA1,0xA1,0xA1,0xA1,0xBF,0x80,0x00,0x0 0,0x04,0x03,0x00,0xFF,0x00,0x41,0x44,0x44,0x44,0x7F,0x44,0x44,0x44,0x44,0x40,0x00},/*" 程",3*/{0x40,0x30,0x10,0x12,0x5C,0x54,0x50,0x51,0x5E,0xD4,0x50,0x18,0x57,0x32,0x10,0x0 0,0x00,0x02,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x02,0x02,0x02,0x02,0x02,0x02,0x00},/*" 学",4*/{0xFE,0x02,0x32,0x4A,0x86,0x0C,0x24,0x24,0x25,0x26,0x24,0x24,0x24,0x0C,0x04,0x00,0xFF,0x00,0x02,0x04,0x83,0x41,0x31,0x0F,0x01,0x01,0x7F,0x81,0x81,0x81,0xF1,0x00},/*" 院",5*/{0x10,0x10,0xD0,0xFE,0x50,0x90,0x00,0x10,0x10,0x10,0xD0,0xFE,0x10,0x10,0x10,0x0 0,0x08,0x06,0x01,0xFF,0x00,0x01,0x10,0x08,0x04,0x43,0x80,0x7F,0x00,0x00,0x00,0x00},/*" 材",0*/{0x20,0x24,0xA8,0x70,0xFF,0x68,0xA4,0x20,0x42,0x8C,0x00,0x00,0xFF,0x00,0x00,0x00,0x08,0x06,0x01,0x00,0xFF,0x00,0x01,0x02,0x02,0x03,0x02,0x02,0xFF,0x01,0x01,0x00},/*" 料",1*/{0x00,0x08,0x08,0x08,0xFF,0x08,0x08,0xF8,0x00,0xF8,0x08,0x08,0x08,0xF8,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x20,0x40,0x3F,0x00,0x7F,0x10,0x10,0x10,0x3F,0x00,0x00},/*" 加",2*/{0x00,0x00,0x02,0x02,0x02,0x02,0x02,0xFE,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x0 0,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00},/*" 工",4*/{0x00,0x00,0x02,0x02,0x02,0x02,0x02,0xFE,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x0 0,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00},/*" 工",4*/{0x10,0x12,0xD2,0xFE,0x91,0x11,0x80,0xBF,0xA1,0xA1,0xA1,0xA1,0xBF,0x80,0x00,0x0 0,0x04,0x03,0x00,0xFF,0x00,0x41,0x44,0x44,0x44,0x7F,0x44,0x44,0x44,0x44,0x40,0x00},/*" 程",5*/};unsignedcharcodeE[][16]={{0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x0 0},/*"C",0*/{0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x0 0},/*"r",1*/{0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x2 0},/*"a",2*/{0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x0 0},/*"s",3*/{0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x0 0},/*"y",4*/{0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x0 0},/*"b",5*/{0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x0 0},/*"o",6*/{0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x0 0},/*"y",7*/{0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x0 0},/*"e",8*/};/*********************** 延时子程序***********************/voiddelay(unsignedintk){unsignedinti;unsignedintj;for(i=0;i<k;i++)for(j=0;j<20;j++);}/*********************** 写命令左***********************/ voidwrite_cmd_1(unsignedcharcommand){cs1=1;cs2=0;Di=0;RW=0;Lcd_Bus=command;//P0 口delay(0);Enable=1;delay(0);Enable=0;}/*********************** 写命令右***********************/ voidwrite_cmd_2(unsignedcharcommand){cs1=0;cs2=1;Di=0;RW=0;Lcd_Bus=command;delay(0);Enable=1;delay(0);Enable=0;}/*********************** 写数据左***********************/ voidwrite_data_1(unsignedchardis_data){cs1=1;cs2=0;Di=1;RW=0;Lcd_Bus=dis_data;delay(0);Enable=1;delay(0);Enable=0;}/*********************** 写数据右***********************/ voidwrite_data_2(unsignedchardis_data){cs1=0;cs2=1;Di=1;RW=0;Lcd_Bus=dis_data;delay(0);Enable=1;delay(0);Enable=0;}/*********************** 清内存左***********************/voidclear_1(void){unsignedcharj,k;cs1=1;cs2=0;write_cmd_1(Page_Add+0);write_cmd_1(Col_Add+0);for(k=0;k<8;k++){write_cmd_1(Page_Add+k);for(j=0;j<64;j++)write_data_1(0x00);}}/*********************** 清内存右***********************/voidclear_2(void){unsignedcharj,k;cs1=0;cs2=1;write_cmd_2(Page_Add+0);write_cmd_2(Col_Add+0);for(k=0;k<8;k++){write_cmd_2(Page_Add+k);for(j=0;j<64;j++)write_data_2(0x00);}}/*********************** 显示汉字 16*16左************************/ voidChinese_disp_1(unsignedcharpag,unsignedcharcol,unsignedcharn) {unsignedchari=0; unsignedcharj=0;cs1=1;cs2=0;for(i=0;i<2;i++){write_cmd_1(Page_Add+pag+i); write_cmd_1(Col_Add+col);for(j=0;j<16;j++)write_data_1(Chinese_character[n][16*i+j]);}}/*********************** 显示汉字 16*16右***********************/ voidChinese_disp_2(unsignedcharpag,unsignedcharcol,unsignedcharn) {unsignedchari=0;unsignedcharj=0;cs1=0;cs2=1;for(i=0;i<2;i++){write_cmd_2(Page_Add+pag+i);write_cmd_2(Col_Add+col);for(j=0;j<16;j++)write_data_2(Chinese_character[n][16*i+j]);}}/*********************** 显示英文 16*8左************************/ voidE_disp_1(unsignedcharpag,unsignedcharcol,unsignedcharn){unsignedchari=0;unsignedcharj=0;cs1=1;cs2=0;for(i=0;i<2;i++){write_cmd_1(Page_Add+pag+i);write_cmd_1(Col_Add+col);for(j=0;j<8;j++)write_data_1(E[n][8*i+j]);}}/*********************** 显示英文 16*8右***********************/ voidE_disp_2(unsignedcharpag,unsignedcharcol,unsignedcharn){unsignedchari=0;unsignedcharj=0;cs1=0;cs2=1;for(i=0;i<2;i++){write_cmd_2(Page_Add+pag+i); write_cmd_2(Col_Add+col);for(j=0;j<8;j++)write_data_2(E[n][8*i+j]); }}/*********************** 液晶屏初始化***********************/ voidinit_lcd(){Lcd_Rst=0;delay(100);Lcd_Rst=1;delay(100);write_cmd_1(Disp_Off);write_cmd_2(Disp_Off);write_cmd_1(Page_Add+0);write_cmd_2(Page_Add+0);write_cmd_1(Start_Line+0);write_cmd_2(Start_Line+0);write_cmd_1(Col_Add+0);write_cmd_2(Col_Add+0);write_cmd_1(Disp_On);write_cmd_2(Disp_On);}/********************* **LCD显示子程序***********************/voiddisplay(void){unsignedchari;for(i=Start_Line;i<0xff;i++) {Chinese_disp_1(0,0,0); Chinese_disp_1(0,16,1); Chinese_disp_1(0,32,2); Chinese_disp_1(0,48,3); Chinese_disp_2(0,0,4); Chinese_disp_2(0,16,5); Chinese_disp_2(0,32,6); Chinese_disp_2(0,48,7);// 西安建筑科技大学Chinese_disp_1(2,16,8);Chinese_disp_1(2,32,9); Chinese_disp_1(2,48,10); Chinese_disp_2(2,0,11); Chinese_disp_2(2,16,12); Chinese_disp_2(2,32,13); // 冶金工程学院Chinese_disp_1(4,16,14); Chinese_disp_1(4,32,15); Chinese_disp_1(4,48,16); Chinese_disp_2(4,0,17); Chinese_disp_2(4,16,18); Chinese_disp_2(4,32,19); 资料加工工程E_disp_1(6,24,0);E_disp_1(6,32,1);E_disp_1(6,40,2);E_disp_1(6,48,3);E_disp_1(6,56,4);E_disp_2(6,0,5);E_disp_2(6,8,6);E_disp_2(6,16,7);E_disp_2(6,24,8);//Crasyboyewrite_cmd_1(i);write_cmd_2(i);delay(3000);// 调整转动速度}//delay(60000);}/*********** 主程序************/ voidmain(void){init_lcd();clear_1();clear_2();while(1){display();}}。
LCD12864驱动程序(无字库)
LCD12864驱动程序(无字库)电路图如下,本人亲自调试过,可用!程序如下:*******************************************************************************主程序:#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,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,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,0x00,0x02,0x07,0x07,0x87,0x83,0x81,0x81,0x80,0x80,0xC0,0xC0,0x80,0x80,0x80,0x80,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,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);void write_com(unsigned char cmdcode);void write_data(unsigned char Dispdata);void frame();void Clr_Scr();void Disp_Img(unsigned char code *img);void Disp_H_Line();void Disp_V_Line();void hz_disp16(unsigned char pag,unsigned char col, unsigned char code *hzk); void init_lcd();void Msg(int flg);void display_imge1(void);void display_imge2(void);。
LCD12864液晶显示器中文说明(DOC)
一、液晶显示模块概述12864A-1汉字图形点阵液晶显示模块,可显示汉字及图形,内置8192个中文汉字(16X16点阵)、128个字符(8X16点阵)及64X256点阵显示RAM(GDRAM)。
主要技术参数和显示特性:电源:VDD 3.3V~+5V(内置升压电路,无需负压);显示内容:128列× 64行显示颜色:黄绿显示角度:6:00钟直视LCD类型:STN与MCU接口:8位或4位并行/3位串行配置LED背光多种软件功能:光标显示、画面移位、自定义字符、睡眠模式等二、外形尺寸1.外形尺寸图2.二、模块引脚说明电源地(GND):0V工作温度(Ta):0~60℃(常温) / -20~75℃(宽温)三、接口时序模块有并行和串行两种连接方法(时序如下):8位并行连接时序图MPU写资料到模块MPU从模块读出资料、串行连接时序图2串行数据传送共分三个字节完成:第一字节:串口控制—格式11111ABCA为数据传送方向控制:H表示数据从LCD到MCU,L表示数据从MCU到LCDB为数据类型选择:H表示数据是显示数据,L表示数据是控制指令C固定为0第二字节:(并行)8位数据的高4位—格式DDDD0000第三字节:(并行)8位数据的低4位—格式0000DDDD串行接口时序参数:(测试条件:T=25℃VDD=4.5V)四、用户指令集1、当模块在接受指令前,微处理顺必须先确认模块内部处于非忙碌状态,即读取BF 标志时BF 需为0,方可接受新的指令;如果在送出一个指令前并不检查BF 标志,那么在前一个指令和这个指令中间必须延迟一段较长的时间,即是等待前一个指令确实执行完成,指令执行的时间请参考指令表中的个别指令说明。
2、“RE ”为基本指令集与扩充指令集的选择控制位元,当变更“RE ”位元后,往后的指令集将维持在最后的状态,除非再次变更“RE ”位元,否则使用相同指令集时,不需每次重设“RE ”位元。
具体指令介绍:1、清除显示 CODE :功能:清除显示屏幕,把DDRAM 位址计数器调整为“00H ” 2、位址归位 CODE :功能:把DDRAM 位址计数器调整为“00H ”,游标回原点,该功能不影响显示DDRAM 3、位址归位 CODE : 功能:把DDRAM 位址计数器调整为“00H ”,游标回原点,该功能不影响显示DDRAM 功能:执行该命令后,所设置的行将显示在屏幕的第一行。
12864的液晶显示程序(无字库)
LCD12864点阵液晶屏,
通过I/O口直接控制,采用模拟时序控制
****************************************************/
#include"12864.h"
LCD_RS = 0;LCD_RW = 0;LCD_E = 1;
//_nop_(); //若晶振速度高,可在此作延时处理
LCD_E = 0;
}
/******************************************************************************
}
LCD_RW=1;LCD_RS=1;LCD_E = 1;//操作允许脉冲信号,高电平读出
//_nop_(); //若晶振速度高,可在此作延时处理
dataR = LCD_Data;
LCD_E= 0;
return dataR;
}
/***********************************************************
LCD_Data = WDLCD;
LCD_E = 1;
//_nop_(); //若晶振速度高,可在此作延时处理
LCD_E = 0; //下降沿写入数据
//_nop_(); //若晶振速度高,可在此作延时处理
}
/***********************************************************
void Clr_All_Lcd(void)
{
clear_LCD(1);
LCD12864液晶显示器中文说明(DOC)
一、液晶显示模块概述12864A-1汉字图形点阵液晶显示模块,可显示汉字及图形,内置8192个中文汉字(16X16点阵)、128个字符(8X16点阵)及64X256点阵显示RAM(GDRAM)。
主要技术参数和显示特性:电源:VDD 3.3V~+5V(内置升压电路,无需负压);显示内容:128列× 64行显示颜色:黄绿显示角度:6:00钟直视LCD类型:STN与MCU接口:8位或4位并行/3位串行配置LED背光多种软件功能:光标显示、画面移位、自定义字符、睡眠模式等二、外形尺寸1.外形尺寸图2.二、模块引脚说明电源地(GND):0V工作温度(Ta):0~60℃(常温) / -20~75℃(宽温)三、接口时序模块有并行和串行两种连接方法(时序如下):8位并行连接时序图MPU写资料到模块MPU从模块读出资料、串行连接时序图2串行数据传送共分三个字节完成:第一字节:串口控制—格式11111ABCA为数据传送方向控制:H表示数据从LCD到MCU,L表示数据从MCU到LCDB为数据类型选择:H表示数据是显示数据,L表示数据是控制指令C固定为0第二字节:(并行)8位数据的高4位—格式DDDD0000第三字节:(并行)8位数据的低4位—格式0000DDDD串行接口时序参数:(测试条件:T=25℃VDD=4.5V)四、用户指令集1、当模块在接受指令前,微处理顺必须先确认模块内部处于非忙碌状态,即读取BF 标志时BF 需为0,方可接受新的指令;如果在送出一个指令前并不检查BF 标志,那么在前一个指令和这个指令中间必须延迟一段较长的时间,即是等待前一个指令确实执行完成,指令执行的时间请参考指令表中的个别指令说明。
2、“RE ”为基本指令集与扩充指令集的选择控制位元,当变更“RE ”位元后,往后的指令集将维持在最后的状态,除非再次变更“RE ”位元,否则使用相同指令集时,不需每次重设“RE ”位元。
具体指令介绍:1、清除显示 CODE :功能:清除显示屏幕,把DDRAM 位址计数器调整为“00H ” 2、位址归位 CODE :功能:把DDRAM 位址计数器调整为“00H ”,游标回原点,该功能不影响显示DDRAM 3、位址归位 CODE : 功能:把DDRAM 位址计数器调整为“00H ”,游标回原点,该功能不影响显示DDRAM 功能:执行该命令后,所设置的行将显示在屏幕的第一行。
LCD12864(不带字库)
LCD12864(不带字库)LCD12864(不带字库)其实看了本版的1602教程以后很容易就可以掌握12864了。
刚才看到有网友要12864教程,俺就把博客里以前练习的一个程序弄过来,算作参考吧。
不足之处请见谅。
这个程序浪费了我很多时间,因为我一直没有找到datasheet,12864的型号实在太多了。
为了这个程序,我在网上找了很多相关的例程,但大多都是C语言写的,可惜俺没学过C,用起来不顺手,遂将其转成汇编,但是转后,程序运行不正常,郁闷啊。
好不容易找个汇编的吧,又写得很乱,没有头绪,没有datasheet,看起来很费劲,最后终于找到一个相关的datasheet,这才完成这个程序。
总结一下:与其费力分析别人的程序,不如看datasheet自己写。
下面总结一下datasheet。
→↑← ONE→且看datasheet:12864点阵型LCD简介12864是一种图形点阵液晶显示器,它主要由行驱动器/列驱动器及128×64全点阵液晶显示器组成。
可完成图形显示,也可以显示8×4个(16×16点阵)汉字。
'700')this.width='700';if(this.height>'700')this.height='700';">在使用12864LCD前先必须了解以下功能器件才能进行编程。
12864内部功能器件及相关功能如下:1. 指令寄存器(IR) IR是用于寄存指令码,与数据寄存器数据相对应。
当D/I=0时,在E信号下降沿的作用下,指令码写入IR。
2.数据寄存器(DR) DR是用于寄存数据的,与指令寄存器寄存指令相对应。
当D/I=1时,在下降沿作用下,图形显示数据写入DR,或在E信号高电平作用下由DR读到DB7∽DB0数据总线。
【0727学习笔记】LCD12864液晶显示技术
【0727学习笔记】LCD12864液晶显示技术-硬件介绍2008-07-27 20:18---- 根据相关资料整理,不对之处,欢迎留言或EMAIL ME niejinbo999# (#换成@) ------ 我是用Proteus仿真的,带字库的LCD12864屏近百大元一个,下载个破解版的Proteus,LCD12864屏直接拖出来就可以用了,想拖几个就拖几个,呵呵,闲话少说,进入正题。
先来看一下Proteus里面的12864长什么样,下图中就是我使用的12864屏,型号为:AMPIRE128X64管脚一共18个。
CS1左半屏片选端,CS2右半屏片选端;VCC、GND就是VCC、GND,没啥好说的;V0液晶显示驱动电压,在网上找的仿真实例中有的这个脚就悬空,我是通过一个电位器接到VCC;RS数据指令选择信号,H为数据,L为指令,有的资料上也叫D/I,我估计是DATA和INSTRUCTIONS这两个单词的缩写;R/W读写选择信号,H为读,L为写,这肯定是READ和WRITE的缩写。
E为LCD使能端,R/W为L时,E信号下降沿锁存DB7-DB0;R/W为H时,E为H,DDRAM数据读到DB7-DB0,如果只写不读的话可以接地处理。
DB0-DB7数据传输端口。
RST复位信号,不过还没弄明白是怎么回事,参考一些资料后接VCC处理。
-VOUT估计和V0差不多,液晶显示驱动电压。
PS:我在网上没找到AMPIRE128X64的资料,但其控制系统和市面上卖的有些是一样的,因此可以参考一下。
我就是参考下面这个型号的资料,需要的朋友可以留下EMIAL。
图片截自深圳彩晶科技的文档资料。
指令说明:一共有7个指令,下面分别加以说明(个人理解)显示开关 0x3e:关;0x3f:开(R/W=0,RS=0)显示起始行 0xc0+i : i取值0至63 (R/W=0,RS=0)设置DDRAM页地址(X地址) 0xb8+i: i取值0至7 (R/W=0,RS=0)设置Y地址 0x40+i:i取值0至63 (R/W=0,RS=0)读状态 R/W为H时,暂未弄明白写数据将数据线上的数据DB7-DB0写到DDRAM ,Y地址指针自动加1 (R/W=0,RS=1)读数据将DDRAM中的数据读入1数据线DB7-DB0 ,Y地址指针自动加1 (R/W=1,RS=1)(用到的很少)DDRAM地址表(注意DB0-DB7在DDRAM里的存储空间,竖起排列)写操作时序(当E信号下降沿时写入数据)小声的说下,资料上是 L有效,时序图里怎么就H了呢?写操作时序(时序参数均为NS级,单片机为US级,故不用考虑延时)读操作时序(时序参数均为NS级,单片机为US级,故不用考虑延时)硬件介绍到此结束,有什么不对之处留言或EMAI告之。
LCD12864 液晶显示屏中文资料
将以上 16 位地址连续写入即可
备注:当 IC1 在接受指令前,微处理器必须先确认其内部处于非忙碌状态,即读取 BF 标志时,BF 需为零,方可接受新的指令;
如果在送出一个指令前并不检查 BF 标志,那么在前一个指令和这个指令中间必须延长一段较长的时间,即是等待前一个指
DB7
H/L
三态数据线
15
PSB
H/L
H:8 位或 4 位并口方式,L:串口方式(见注释 1)
16
NC
-
空脚
17 /RESET H/L
复位端,低电平有效(见注释 2)
18 VOUT
-
LCD 驱动电压输出端
19
A
VDD
背光源正端(+5V)(见注释 3)
20
K
VSS
背光源负端(见注释 3)
*注释 1:如在实际应用中仅使用串口通讯模式,可将 PSB 接固定低电平,也可以将模块上的 J8 和“GND”用焊锡短接。 *注释 2:模块内部接有上电复位电路,因此在不需要经常复位的场合可将该端悬空。 *注释 3:如背光和模块共用一个电源,可以将模块上的 JA、JK 用焊锡短接。
● 字型产生 RAM(CGRAM) 字型产生 RAM 提供图象定义(造字)功能, 可以提供四组 16×16 点的自定义图象空间,使用
者可以将内部字型没有提供的图象字型自行定义到 CGRAM 中,便可和 CGROM 中的定义一样地通过 DDRAM 显示在屏幕中。
● 地址计数器 AC 地址计数器是用来贮存 DDRAM/CGRAM 之一的地址,它可由设定指令暂存器来改变,之后只要读取或是写 入 DDRAM/CGRAM 的值时,地址计数器的值就会自动加一,当 RS 为“0”时而 R/W 为“1”时,地址计数器的值会被读取到 DB6——DB0 中。
无字库12864液晶模块应用
无字库12864液晶模块应用
图1
在上次介绍的日历钟的基础上扩展一下:让它具备检测大气温度和湿度的
功能,一天24 小时不间断运行并定时检测,于是,日历钟就摇身一变成为一
个小小温湿度计啦。
虽然气象要素很多,不过我们最常用的就是气温和湿度。
一个是冷热程度,一个是环境空气中含水蒸气的多少。
一般家用温度计很常见,湿度计就比较少,以前有一种干湿球温度计,但是用起来比较麻烦,准确度也不高。
现在应用电子技术我们就可以做一个可以同时显示温度、湿度、时间的小仪器,放在家里以便随时监测我们的小环境。
它的特点如下:
1.在单片机ATMega8L-8PU(以下简称M8)和日历钟电路DS1302 的基础上,使用一个在工厂经过精密校准的数字式温度、湿度传感器AM2301 作为探头;
2.当24 小时连续工作时,纵然工作电流仅为几毫安,也不宜使用纽扣电池
供电。
这次选用可充电的3.6V 聚合物锂电池,使它的放置地点可以不受电源
限制,可以在室内,也可以在不受阳光直射和雨水接触的室外;
3.具有文字和图形界面,可以显示温度和湿度数值,以及12 小时内的湿度
变化记录曲线,为什么是湿度曲线呢?因为气温的变化规律一般比较稳定,湿度就不一样了,我们可以从湿度变化趋势估计一下未来的晴雨可能,这比看燕。
LCD12864显示
→未(已)注册(10)
按键注册
→注销(11)
按键注销
→事件报告(8)
无
→信息点播(9)
无
→电话本(10)
无
→短消息(11)
→查看短消息(0)
无
→清空短消息(1)
→系统重启(12)
15:39 44KM/H
15:38 44KM/H
15:37 44KM/H(1)
→行驶里程(3)
初始:999999.9KM
累计:999999.9KM
→连续驾驶时间(4)
09小时56分钟
最多99小时59分
→超时驾驶记录(5)
记录1驾驶证号:(0)
123456789012345678
2012-01-23 01:35:34起
1:A B C D E F G H I J K
2:L M N O P Q R S T U
3:V W X Y Z
4:鲁京津沪渝冀豫云
5:辽黑湘皖新苏浙赣
6:鄂桂甘晋蒙陕吉闽
7:贵粤青藏川宁琼学
一级菜单
二级菜单
三级菜单
备注
→车辆信息(0)
VIN:12345678901234567(0)
车牌号:鲁A12345
默认:
时间、速度、定位模块状态、
警示:超时驾驶,驾驶员身份登录,速度状态等
GSM强度
GPS卫星
0
9
1
0
2
K
M
/
H
2
-
0
1
-
0
4
1
5
:
2
4
:
1
2
直接汉字停行(12X12)
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
/**************************************************************************在无字库的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;}}。