51单片机 12864液晶显示并口和串口连接程序

合集下载

12864液晶屏幕使用说明及程序

12864液晶屏幕使用说明及程序

12864使用说明一、串/并接口1.1 串口接口管脚信号*注释1:如在实际应用中仅使用并口通讯模式,可将PSB 接固定高电平。

*注释2:模块内部接有上电复位电路,因此在不需要经常复位的场合可将该端悬空。

*注释3:如背光和模块共用一个电源,可以将模块上的JA、JK 用焊锡短接。

1.2 并行接口管脚信号*注释1:如在实际应用中仅使用并口通讯模式,可将PSB 接固定高电平。

*注释2:模块内部接有上电复位电路,因此在不需要经常复位的场合可将该端悬空。

*注释3:如背光和模块共用一个电源,可以将模块上的JA、JK 用焊锡短接。

二、模块主要硬件构成说明控制器接口信号说明:2.1、RS,R/W的配合选择决定控制界面的4种模式:2.2、E信号●忙标志BFBF 标志提供内部工作情况.BF=1 表示模块在进行内部操作,此时模块不接受外部指令和数据.BF=0 时, 模块为准备状态,随时可接受外部指令和数据.利用STATUS RD 指令,可以将BF 读到DB7 总线,从而检验模块之工作状态.●字型产生ROM(CGROM)字型产生ROM(CGROM)提供8192 个此触发器是用于模块屏幕显示开和关的控制。

DFF=1 为开显示(DISPLAY ON),DDRAM 的内容就显示在屏幕上,DFF=0 为关显示(DISPLAY OFF)。

DFF 的状态是指令DISPLAY ON/OFF 和RST 信号控制的。

●显示数据RAM(DDRAM)模块内部显示数据 RAM 提供 64×2 个位元组的空间,最多可控制 4 行 16 字(64 个字)的中文字型显示,当写入显示数据 RAM 时,可分别显示 CGROM 与CGRAM 的字型;此模块可显示三种字型,分别是半角英、数字型(16*8)、CGRAM 字型及 CGROM 的中文字型。

三种字型的选择,由在 DDRAM 中写入的编码选择,在0000H—0006H 的编码中(其代码分别是0000、0002、0004、0006 共4 个)将选择 CGRAM 的自定义字型,02H—7FH 的编码中将选择半角英数字的字型,至于A1 以上的编码将自动的结合下一个位元组,组成两个位元组的编码形成中文字型的编码BIG5(A140—D75F),GB(A1A0-F7FFH)。

12864液晶显示程序51驱动

12864液晶显示程序51驱动

#include <reg52.h>#include <intrins.h>sbit LCD_RS =P0^0; //L:COMMAND; H:DATA sbit LCD_RW =P0^1; //L:WRITE; H:READ sbit LCD_E =P0^2; //INPUT ENABLEsbit LCD_CS1 =P0^3; //L有效sbit LCD_RES =P0^4; //L有效#define data_bus P2#define control_bus P0#define uchar unsigned char#define uint unsigned int//=====延时N微秒==============void delay_nus(uint n){while(n--);return;}//=====延时N毫秒==============void delay_nms(uint n){int i;for(i=0;i<n;i++)delay_nus(123);}//=====忙检测=================void check_busy(void){uchar read_data=0xff;data_bus=0xff;LCD_RS=0;LCD_RW=1; //读命令LCD_CS1=0; //片使能while((read_data&0x80)==0x80){LCD_E=1;_nop_();_nop_();read_data=data_bus;LCD_E=0;}LCD_E=0;LCD_CS1=1; //片禁能}//=====写命令到寄存器========= void send_cmd(uchar cmd) small{check_busy();LCD_RS=0; //写的是命令LCD_RW=0; //写命令LCD_CS1=0; //片使能data_bus=cmd;LCD_E=1; //使能_nop_();_nop_();LCD_E=0;_nop_();_nop_();LCD_CS1=1; //片禁能}//=====写数据到DDRAM========= void send_dat(uchar dat) small{check_busy();LCD_RS=1; //写的是数据LCD_RW=0; //写数据LCD_CS1=0; //片使能data_bus=dat;LCD_E=1;_nop_();_nop_();LCD_E=0;_nop_();_nop_();LCD_CS1=1; //片禁能}//=======初始化============== void lcd_initial(void) small{LCD_RES=0;delay_nms(50);LCD_RES=1;LCD_E=0;delay_nms(50);send_cmd(0xA0);send_cmd(0xC8);send_cmd(0xA2);send_cmd(0x2C);send_cmd(0x2E);send_cmd(0x2F);send_cmd(0x25);send_cmd(0x81);send_cmd(0x14);send_cmd(0xAF);send_cmd(0xE0);send_cmd(0x40);}//=======写列地址==============void Set_Colume_Address(unsigned char dat){unsigned char tmp;tmp=dat>>4;send_cmd(0x10|tmp); //送列地址高三位tmp=0x0f&dat;send_cmd(tmp); //送列地址低四位}code unsigned char number[][16] = {/*-- 文字: 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,0x20,0x00,0x00,/*-- 文字: 2 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,/*-- 文字: 3 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,/*-- 文字: 4 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,/*-- 文字: 6 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,/*-- 文字: 7 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,/*-- 文字: 8 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,/*-- 文字: 9 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,/*-- 文字: : --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00, /*-- 文字: - --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01}; code unsigned char Hz[][32] = {/*-- 文字: 中--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0xFC,0x08,0x08,0x08,0x08,0xFF,0x08,0x08,0x08,0x08,0xFC,0x08,0x00,0x00, 0x00,0x00,0x07,0x02,0x02,0x02,0x02,0xFF,0x02,0x02,0x02,0x02,0x07,0x00,0x00,0x00,/*-- 文字: 鼎--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0xF8,0x00,0x00,0x7E,0x52,0x66,0x4A,0x52,0x7E,0x00,0x00,0xF8,0x00,0x00, 0x00,0x84,0x65,0x1D,0x05,0x05,0xFF,0x00,0x00,0xFF,0x05,0x05,0x05,0xFD,0x00,0x00,/*-- 文字: 技--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x08,0x08,0x88,0xFF,0x48,0x28,0x00,0xC8,0x48,0x48,0x7F,0x48,0xC8,0x48,0x08,0x00, 0x01,0x41,0x80,0x7F,0x00,0x40,0x40,0x20,0x13,0x0C,0x0C,0x12,0x21,0x60,0x20,0x00,/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x10,0x10,0x10,0x10,0x90,0x50,0xFF,0x50,0x90,0x12,0x14,0x10,0x10,0x10,0x00, 0x10,0x10,0x08,0x04,0x02,0x01,0x00,0x7F,0x00,0x00,0x01,0x06,0x0C,0x18,0x08,0x00 };/****显示汉字的程序****/void DisplayHz(unsigned int Page,unsigned int Col,unsigned char Hz[],unsigned int zilie) {unsigned int PageCnt,ColCnt;for(PageCnt = Page;PageCnt < Page+2;PageCnt ++){send_cmd(0xb0|PageCnt); //page addressSet_Colume_Address(Col);for(ColCnt = 0;ColCnt < zilie;ColCnt ++){send_dat(Hz[(PageCnt-Page)*zilie + ColCnt]);}}}//=====主程序===================void main (void){unsigned char month=0,nian=10,yue=1,tian=1,shi=0,fen=0,miao=0,i=0,j=0; unsigned char months[12]={31,28,31,30,31,30,31,31,30,31,30,31};lcd_initial();send_cmd(0xa6);for(i=0;i<8;i++) //清屏{send_cmd(0xb0|i);Set_Colume_Address(0);for(j=0;j<128;j++)send_dat(0);}while(1){if(++miao>59){miao=0;if(++fen>59){fen=0;if(++shi>23){shi=0;if(++tian>months[month]){tian=0;if(++yue>11){yue=1;nian++;}}}}}DisplayHz(0,0,number[nian/10],8);DisplayHz(0,16,number[nian%10],8);DisplayHz(0,32,number[11],8);DisplayHz(0,48,number[yue/10],8);DisplayHz(0,64,number[yue%10],8);DisplayHz(0,80,number[11],8);DisplayHz(0,96,number[tian/10],8);DisplayHz(0,112,number[tian%10],8);DisplayHz(3,0,number[shi/10],8);DisplayHz(3,16,number[shi%10],8);DisplayHz(3,32,number[10],8);DisplayHz(3,48,number[fen/10],8);DisplayHz(3,64,number[fen%10],8);DisplayHz(3,80,number[10],8);DisplayHz(3,96,number[miao/10],8);DisplayHz(3,112,number[miao%10],8);DisplayHz(6,14,Hz[0],16);DisplayHz(6,42,Hz[1],16);DisplayHz(6,70,Hz[2],16);DisplayHz(6,98,Hz[3],16);delay_nms(6000);}}。

12864液晶显示器(ST7920)显示程序(并口)

12864液晶显示器(ST7920)显示程序(并口)

12864液晶显示器(ST7920)显示程序(并口) 附字模软件作者:纪小年16 七月2009 时间:下午10:25 and have 10 条评论前两天写了一个ST7920控制12864显示的串口程序,今天瞎逛的时候发现了这个超强悍的并口程序,转载一下。

来源:CnChina做了比较详细的注释,看不懂的可以问我。

下面的图片中12864所显示的logo就是我用这个程序得到的。

附程序:/******************************************************************** **********Copyright 2007All rights reserved.文件名: .c模块名称:st7920 并行方式驱动12864液晶驱动功能概要:st7920显示驱动取代版本:0.0.1修改人:pulan完成日期:2007.07.08升级说明:createCPU: stc89c58 主频:11.0592M液晶型号:128*64 生产厂家:驱动芯片:st7920********************************************************************* *********/#include#define uint unsigned int#define uchar unsigned char#define x1 0x80 //1000 0000#define x2 0x88 //1000 1000#define y 0x80 //1000 0000#define comm 0 //定义传送指令代码为0#define dat 1 //定义传送数据代码为1sbit RS = P2^0; //H=数据; L=指令;sbit RW = P2^1; //H=读操作; L=写操作;sbit E = P2^3; //使能端sbit PSB= P2^4; //H=并口; L=串口;sbit RST= P2^2; //复位信号低电平有效sbit busy=P0^7; //LCD忙信号void wr_lcd (uchar dat_comm,uchar content);void chk_busy (void);void delay (uint us);uchar code tab1[]={"本系列中文模块内""任意位置反白显示""置二级字库,可在""使用更方便更灵活"};uchar code tab31[]={"金鹏科技有限公司""Golden Palm TECH"};uchar code tab32[]={/*-- 调入了一幅图像:F:\梁\画图\HOCO12832.bmp --*//*-- 宽度x高度=128x32 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x07,0xF0,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x7F,0x80,0x00,0x00,0x00,0x00,0x18,0x0C,0x00,0x00,0x01,0x00,0x00 ,0x00,0x00,0x01,0xFF,0x80,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x13,0x10,0x03 ,0xFE,0x00,0x03,0xFF,0xC0,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x3F,0x30,0x1F ,0xFF,0xC0,0x03,0xFF,0xE0,0x00,0x00,0x00,0x00,0x8C,0x03,0xF0,0x00,0x7F,0xE0,0x7C ,0x01,0xE0,0x03,0xFF,0xF0,0x00,0x00,0x00,0x01,0x36,0x06,0xC0,0x00,0x5F,0xC0,0xFF ,0xFC,0x60,0x01,0xFF,0xF0,0x00,0x00,0x00,0x02,0x1B,0x0F,0x80,0x00,0xFF,0x01,0xFE ,0x0F,0x30,0x00,0xEF,0xF0,0x00,0x00,0x00,0x02,0x6D,0x9F,0x00,0x00,0x3E,0x03,0xFF ,0xF1,0x90,0x00,0xFF,0xF8,0x00,0x00,0x00,0x04,0x36,0xFE,0x00,0x01,0xFF,0x07,0xFF ,0xFC,0x90,0x00,0xEF,0xFF,0xFF,0x80,0x00,0x04,0xDB,0x7E,0x00,0x03,0xFF,0x87,0xFF ,0xFC,0xD0,0x00,0x0F,0xFF,0xFF,0xC0,0x00,0x04,0x6D,0xFC,0x00,0x07,0xFF,0x8F,0xFF ,0xFE,0x50,0x00,0x0F,0xFF,0xFF,0xE0,0x00,0x04,0x36,0xFC,0x10,0x07,0xFF,0x8F,0xFF ,0xFE,0x90,0x00,0x0F,0xFF,0xFF,0xE0,0x00,0x04,0x1B,0xF8,0x10,0x07,0xFF,0xCF,0xFF ,0xFE,0x80,0x00,0x0F,0xFF,0xFF,0xF0,0x00,0x04,0x0F,0xF8,0x10,0x07,0xFF,0xFF,0xFF ,0xFA,0x00,0x00,0x07,0xFF,0xFF,0xF0,0x00,0x04,0x07,0xF0,0x10,0x07,0xFF,0xFF,0xFF ,0xFA,0x00,0x00,0xFF,0xFF,0xFF,0xF8,0x00,0x02,0x03,0xF0,0x20,0x07,0xFF,0xFF,0xFF ,0xBA,0x00,0x00,0xFD,0xFF,0xFF,0xFC,0x00,0x02,0x03,0xF0,0x20,0x03,0xFF,0xFF,0xDF ,0xB8,0x00,0x00,0xC1,0xC0,0x3F,0xFC,0x00,0x01,0x01,0xE0,0x40,0x00,0xFF,0xFF,0xDF ,0xB0,0x00,0x00,0x81,0xC0,0x3F,0xCE,0x00,0x00,0x81,0xE0,0x80,0x00,0x7F,0xFF,0xDF ,0xA0,0x00,0x00,0x81,0x80,0x1D,0xCF,0x00,0x00,0x41,0xE1,0x00,0x00,0x3F,0xFF,0x9B ,0x00,0x00,0x01,0x83,0x80,0x1F,0xC7,0x80,0x00,0x21,0xE2,0x00,0x00,0x1F,0xFD,0xB6 ,0x00,0x00,0x01,0xC3,0x00,0x0E,0xE6,0x80,0x00,0x19,0xEC,0x00,0x00,0x07,0xFE,0x20 ,0x00,0x00,0x00,0xC3,0x00,0x07,0x67,0x40,0x00,0x07,0xF0,0x00,0x00,0x03,0x3E,0x00 ,0x00,0x00,0x00,0x02,0x00,0x03,0xE7,0xA0,0x00,0x00,0x00,0x00,0x00,0x02,0x8E,0x00 ,0x00,0x00,0x00,0x06,0x00,0x03,0x83,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x03,0x00 ,0x00,0x00,0x00,0x06,0x00,0x07,0x03,0x00,0x77,0x46,0x74,0x24,0x80,0x06,0x04,0x00 ,0x00,0x00,0x00,0x1C,0x00,0x06,0x00,0x00,0x55,0x45,0x54,0x57,0x80,0x00,0x00,0x00 ,0x00,0x00,0x00,0x1C,0x00,0x0E,0x00,0x00,0x45,0x45,0x74,0x57,0x80,0x08,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x00,0x55,0x45,0x44,0x74,0x80,0xF0,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x77,0x76,0x47,0x54,0x80,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00};uchar code tab5[]={/*-- 调入了一幅图像:F:\梁\画图\COCK.bmp --*//*-- 宽度x高度=128x64 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,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,0x00,0x80,0x00,0x0F,0xFF,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x43,0x01,0x80,0x00,0x7F,0xFF,0xF0,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0xFF,0x07,0x00,0x07,0xFF,0xFF,0xFE,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x01,0x3F,0xFC,0x1E,0x00,0x1F,0xFF,0xFF,0xFF,0x80,0x00 ,0x00,0x00,0x00,0x00,0x00,0x01,0xBF,0xFF,0xFC,0x00,0x7F,0xFC,0x00,0x7F,0xC0,0x00 ,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xF0,0x00,0xFF,0xC0,0x00,0x0F,0xE0,0x00 ,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xE0,0x03,0xFF,0xFF,0xFC,0x01,0xF0,0x00 ,0x00,0x00,0x00,0x00,0x00,0x01,0xDF,0xFF,0xC0,0x07,0xFF,0xFF,0xFF,0x80,0xF0,0x00 ,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0x00,0x0F,0xFF,0xFF,0xFF,0xE0,0x38,0x00 ,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xF8,0x00,0x1F,0xFF,0xF0,0x03,0xF8,0x38,0x00 ,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xE0,0x00,0x3F,0xFF,0xFF,0xC0,0x7C,0x18,0x00 ,0x00,0x00,0x00,0x00,0x00,0x04,0x7F,0xF0,0x00,0x3F,0xFF,0xFF,0xF8,0x1E,0x08,0x00 ,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xF8,0x00,0x7F,0xFF,0xFF,0xFE,0x0F,0x08,0x00 ,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFC,0x00,0xFF,0xFF,0xFF,0xFF,0x87,0x08,0x00 ,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFE,0x00,0xFF,0xFF,0xFF,0xFF,0x83,0x88,0x00 ,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFE,0x01,0xFF,0xFF,0xFF,0xFF,0xC3,0x88,0x00 ,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFE,0x01,0xFF,0xFF,0xFF,0xFF,0xE1,0x88,0x00 ,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFE,0x03,0xFF,0xFF,0xFF,0xFF,0xE1,0x88,0x00 ,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFE,0x03,0xFF,0xFF,0xFF,0xFF,0xF1,0x88,0x00 ,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFE,0x03,0xFF,0xFF,0xFF,0xFF,0xF3,0x08,0x00 ,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0x07,0xFF,0xFF,0xFF,0xFF,0xF2,0x10,0x00 ,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0x8F,0xFF,0xFF,0xFF,0xFF,0xF0,0x20,0x00 ,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x00 ,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x70,0x00,0x00 ,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0x70,0x00,0x00 ,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0x70,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0x7F,0x20,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xBF,0xFF,0x7F,0x20,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xDF,0xFF,0x7E,0x20,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xDF,0xFF,0x3E,0x40,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xCF,0xFF,0x3C,0x40,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xCF,0xFE,0x38,0x40,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xFF,0x8F,0xFE,0x38,0x40,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0x8F,0xFE,0x30,0x40,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x1F,0x7C,0x20,0x40,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x1E,0x78,0x00,0x40,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFE,0x1E,0xF0,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xDA,0x3C,0xE0,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xF2,0x30,0x80,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xF1,0x20,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x7F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x72,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x40,0x04,0xD8,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x08,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x0C,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x40,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x0F,0xE2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00};/******************************************************************** *********************** 函数名称:init_lcd* 功能描述:初始化LCD********************************************************************* *********************/void init_lcd (void){RST = 1;PSB = 1;wr_lcd(comm,0x30); //0011 0000 扩充功能设定——8位数据基本指令操作wr_lcd(comm,0x01); //0000 0001 清屏——将DDRAM填满"20H",并且设定DDRAM的地址计数器为"00H"wr_lcd(comm,0x06); //0000 0110 进入点设定——指定在数据的读取与写入时,设定游标的移动方向wr_lcd(comm,0x0c); //0000 1100 游标或显示移位控制——开显示,关游标}/******************************************************************** *********************** 函数名称:chn_disp* 功能描述:显示汉字或字符********************************************************************* *********************/void chn_disp(uchar code *chn){uchar i,j; //i为横坐标,j为纵坐标wr_lcd(comm,0x30); //0011 0000 扩充功能设定——8位数据基本指令操作wr_lcd(comm,0x80); //1000 0000 设定DDRAM地址——0000000for(j=0;j<4;j++) //写四行数据{for(i=0;i<16;i++)wr_lcd(dat,chn[j*16+i]);}}/******************************************************************** *********************** 函数名称:chn_disp1* 功能描述:上半屏显示汉字或字符********************************************************************* *********************/void chn_disp1(uchar code *chn){uchar i,j;wr_lcd(comm,0x30); //0011 0000 扩充功能设定——8位数据基本指令操作wr_lcd(comm,0x80); //1000 0000 设定第一行的DDRAM 地址——0x80j=0; //第一行for(i=0;i<16;i++)wr_lcd(dat,chn[j*16+i]);wr_lcd(comm,0x90); //1001 0000 设定第二行的DDRAM 地址——0x90j=1; //第二行for(i=0;i<16;i++)wr_lcd(dat,chn[j*16+i]);}/******************************************************************** *********************** 函数名称:img_disp* 功能描述:显示图形********************************************************************* *********************/void img_disp(uchar code *img){uchar i,j;for(j=0;j<32;j++) //绘制上半屏{for(i=0;i<8;i++){wr_lcd(comm,0x34); //0011 0100 扩充功能设定——8位数据扩充指令操作绘图开wr_lcd(comm,y+j); //1xxx xxxx 设定绘图RAM——先设定垂直(列)地址AC6 AC5…AC0wr_lcd(comm,x1+i); //1000 0xxx 设定绘图RAM——再设定水平(行)地址AC3AC2AC1AC0wr_lcd(comm,0x30); //0011 0000 扩充功能设定——8位数据基本指令操作wr_lcd(dat,img[j*16+i*2]);wr_lcd(dat,img[j*16+i*2+1]);}}for(j=32;j<64;j++) //绘制下半屏{for(i=0;i<8;i++){wr_lcd(comm,0x34); //0011 0100 扩充功能设定——8位数据扩充指令操作绘图开wr_lcd(comm,y+j-32); //1xxx xxxx 设定绘图RAM——先设定垂直(列)地址AC6 AC5…AC0wr_lcd(comm,x2+i); //1000 1xxx 设定绘图RAM——再设定水平(行)地址AC3AC2AC1AC0wr_lcd(comm,0x30); //0011 0000 扩充功能设定——8位数据基本指令操作wr_lcd(dat,img[j*16+i*2]);wr_lcd(dat,img[j*16+i*2+1]);}}wr_lcd (comm,0x36); //0011 0110 扩充功能设定——8位数据扩充指令操作绘图关}/******************************************************************** *********************** 函数名称:img_disp1* 功能描述:下半屏显示图形********************************************************************* *********************/void img_disp1(uchar code *img){uchar i,j;for(j=0;j<32;j++){for(i=0;i<8;i++){wr_lcd(comm,0x34);wr_lcd(comm,y+j);wr_lcd(comm,x2+i);wr_lcd(comm,0x30);wr_lcd(dat,img[j*16+i*2]);wr_lcd(dat,img[j*16+i*2+1]);}}wr_lcd(comm,0x36);}/******************************************************************** *********************** 函数名称:lat_disp* 功能描述:显示点阵********************************************************************* *********************/void lat_disp(uchar data1,uchar data2){uchar i,j,k,x;x=x1; //1000 0000for(k=0;k<2;k++) //第一次循环x=1000 0000 第二次循环x=1000 1000{for(j=0;j<16;j++){for(i=0;i<8;i++){wr_lcd(comm,0x34); //0011 0100 扩充功能设定——8位数据扩充指令操作绘图开wr_lcd(comm,y+j*2);wr_lcd(comm,x+i);wr_lcd(comm,0x30);wr_lcd(dat,data1);wr_lcd(dat,data1);}for(i=0;i<8;i++){wr_lcd(comm,0x34);wr_lcd(comm,y+j*2+1);wr_lcd(comm,x+i);wr_lcd(comm,0x30);wr_lcd(dat,data2);wr_lcd(dat,data2);}}x=x2;}wr_lcd(comm,0x36);}/******************************************************************** *********************** 函数名称:con_disp* 功能描述:当data1=0xff,data2=0xff时,在x0,y0处反白显示16xl*yl ********************************************************************* *********************/void con_disp(uchar data1,uchar data2,uchar x0,uchar y0,uchar xl,uchar yl){uchar i,j;for(j=0;j< pre> 。

12864程序(51总线方式)

12864程序(51总线方式)

; 12864接口程序(MCS51总线方式);*************************************************************************** ;连线图: *LCM---8031* *LCM---8031* *LCM------------8031* *LCM----------8031* ; *DB0---P0.0* *DB4---P0.4* *C/D-------------P2.0* */RD---------P3.7* ; *DB1---P0.1* *DB5---P0.5* *CE--------------P2.1*; *DB2---P0.2* *DB6---P0.6* */RW-------------P3.6; *DB3---P0.3* *DB7---P0.7* */RST------------VDD (详见说明书);注:8031的晶振频率为12MHz;************************************************************************** XPOS EQU 20H ;列方向地址指针(用于LCDPOS子程序)YPOS EQU 21H ;行方向地址指针(用于LCDPOS子程序)BUFFER EQU 22HBUFFERH EQU 23H;CEPIN P2.1;C/DPIN P2.0 0:DATA 1:COMMANDCADDR EQU 0100HDADDR EQU 0000HORG 0000HJMP STARTSTART: MOV SP,#60HMAIN:CALL LCDRESETMOV A,#55HCALL LCDFILLMOV A,#0FFHCALL LCDFILLCALL MAPMOV A,#01HCALL LCDFILLMOV DPTR,#STRING1CALL PUTSTRCALL PUTSTRMOV A,#00HCALL LCDFILLCALL TEXTONJMP STARTTEXTON:MOV A,#97H ;TEXT ONCALL LCDWC ;(文本显示打开)MOV R2,#30MOV R3,#00HMOV A,#41H ;TEXT AREA SETCALL LCDWC3 ;(文本区域设置)MOV R2,#00HMOV R3,#00HMOV A,#40H ;TEXT HOME ADDRESS SETCALL LCDWC3 ;(文本区首地址)MOV DPTR,#0000HMOV R1,#00HMOV XPOS,#0MOV YPOS,#0TEXT: MOV 20H,R1MOV A,20HMOV 20H,ACALL LCDWRITEINC R1CALL DELAYCJNE R1,#80H,TEXTRETDELAY400MS:MOV R0,#20 ;延时子程序(400MS)DL4_PA: MOV R1,#100DL4_PB: MOV R2,#100DJNZ R2,$DJNZ R1,DL4_PBDJNZ R0,DL4_PARETDELAY:MOV R6,#2DLY_PA: MOV R5,#0DLY_PB: MOV R4,#0DJNZ R4,$DJNZ R5,DLY_PBDJNZ R6,DLY_PARETGETSTRCHAR:GSC_PA:CLR AMOVC A,@A+DPTRINC DPTRMOV B,AINC ACLR CJZ GSC_LAXCLR AMOVC A,@A+DPTRINC DPTRSETB CGSC_LAX:RETPUTSTR:CALL DELAYCALL GETSTRCHARPUSH DPLPUSH DPHJNC PSR_LAXJNB B.7,PSR_LBY ;CHINESE:CALL HZKPOSCALL PUTCHARDOTCALL PUTCHARDOTJMP PSR_LBX PSR_LBY:;ENGLISH:CALL HZKPOSCALL PUTCHARDOT PSR_LBX:POP DPHPOP DPLJMP PUTSTRPSR_LAX:POP DPHPOP DPLRET PUTCHARDOT:MOV R7,#16PAC_PA:CLR AMOVC A,@A+DPTRCALL LCDWRITEINC YPOSINC DPTRDJNZ R7,PAC_PACLR CMOV A,XPOSSUBB A,#29JNZ PAC_LAYMOV XPOS,#0JMP PAC_LAX PAC_LAY:INC XPOSCLR CMOV A,YPOSSUBB A,#16MOV YPOS,APAC_LAX:RETHZKPOS:MOV R2,#5HTP_PA:CLR CRLC AXCH A,BRLC AXCH A,BDJNZ R2,HTP_PAMOV DPTR,#HZKDOTADD A,DPLMOV DPL,AMOV A,BADDC A,DPHMOV DPH,ARETLCDFILL: ;LCD整屏显示A的内容 MOV R7,AMOV YPOS,#0LFL_PB: MOV XPOS,#0LFL_PA: MOV A,R7CALL LCDWRITE ;定位并写数据CALL CUSORNEXTMOV A,XPOSJNZ LFL_PA ;XPOS。

51单片机 12864液晶显示并口和串口连接程序

51单片机  12864液晶显示并口和串口连接程序
sent(DATA&0XF0); //先写高位后写低位
sent((DATA&0X0F)<<4); //低位
}
void AUTO(uchar *add)
{
uchar cnt=0;
while(*(add+cnt)!='\0')
{
writLCD(1,*(add+cnt));
cnt++;
}
}
void wirtthings(uchar lines,uchar *add)//writ data to which line
else
RW=0;
delay(10);
SCK=1;
DATA=DATA<<1;
}
}
void writLCD(bit flag,uchar DATA) //writ COM or data in address
{
if(flag)
sent(0xfa);//1写数据
else
sent(0xf8);//0写指令
//writLCD(0,0x01);
wirtthings(4,"什么,only You!");
//writLCD(0,0x01);
wirtthings(1,"联系方式:");
//writLCD(0,0x01);
wirtthings(2,"QQ:452658536");
delay(100);
writLCD(0,0x01);
}
}
void delay(uchar i)
{
uchar j;
while(i--)

51单片机经典C程序(12864)

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++) {;}}/*----------------------------------------------------------------------------下面这个函数用于液晶模块的忙信号检测。

12864液晶显示程序(串口)

12864液晶显示程序(串口)

/*------------------初始化-----------------*/
void init_lcd (void)
{
// rst=1;
wr_lcd (comm,0x30); /*30---基本指令动作*/
wr_lcd (comm,0x01); /*清屏,地址指针指向00H*/
void lcd_string(uchar x0,uchar y0,uchar k,uchar *chn)
{
uchar adr,i;
switch(x0)
{
case 0: adr = 0x80 + y0;
break; //在第1行y列显示
case 1: adr = 0x90 + y0;
break; //在第2行y列显示
case 2: adr = 0x88 + y0;
break; //在第3行y列显示
case 3: adr = 0x98 + y0;
break; //在第4行y列显示
default: ;
}
wr_lcd (comm,0x30);
{
case 0: adr = 0x80 + y0;
break; //在第1行y列显示
case 1: adr = 0x90 + y0;
break; //在第2行y列显示
case 2: adr = 0x88 + y0;
break; //在第3行y列显示
case 3: adr = 0x98 + y0;
#define comm 0
#define dat 1

12864图形液晶显示模块与51系列单片机接口技术

12864图形液晶显示模块与51系列单片机接口技术

单片机与可编程器件液晶显示模块以其微功耗、体积小、显示内容丰富、模块化、接口电路简单等诸多优点得到广泛应用。

液晶显示模块分字符型和点阵型两种,前者只能显示常用的字符,点阵型液晶显示模块除显示字符外还能显示各种图形和汉字。

目前,尽管液晶显示模块种类繁多,但其结构及控制方法是一样的,本文以常用的128×64液晶显示模块为例介绍液晶显示模块的工作原理及其与51系列单片机的接口技术。

12864图形液晶显示模块12864液晶显示模块表示横向有128点,纵向有64点,可显示16×16中文字4行,每行8个字,外形和引脚排列如图1所示。

1. 引脚功能 引脚功能如表1所示。

2. 显示DDRAM与X地址、Y地址排列方式 DDRAM是模块自带的存储单元,用来存放图形信息或数据,DDRAM存储单元与液晶显示屏之间存在一一对应关系,数据为1表示显示选择,对应屏幕亮;数据为0表示显示非选择,对应屏幕不亮。

DDRAM与X、Y地址和显示位置的关系如表2所示。

3.12864液晶显示模块指令12864液晶显示模块基本操作指令如表3所示。

(1)读取状态字 当R/W=1,D/I=0时,在E信号为高的作用下,状态字分别输出到数据总线上。

状态字是了解模块当前工作状态的唯一的信息渠道,在每次对模块操作之前,都要读出状态字判断BUSY是否为“0”。

若不为“0”,则计算机需要等待,直至BUSY =0为止。

(2)显示开关设置 D=1开显示,D=0关显示。

(3)显示起始行设置 指令表中DB5~DB0为显示起始行的地址,取值在0~3FH(1~64行)范围内,它规定了显示屏上最顶一行所对应的显示存储器的行地址。

(4 ) 页面地址设置 页面地址是DDRAM的行地址。

8行为一页,DDRAM共64行即8页,DB2 ̄DB0表示0 ̄7页。

(5)列地址设置 列地址是DDRAM的列地址。

共64列,12864图形液晶显示模块与51系列单片机接口技术・湖南邵阳学院电气信息工程学院 江世明・摘要 文章以128×64液晶显示模块为例,系统地介绍了12864图形液晶显示模块的结构特征、指令系统、工作时序及与51系列单片机接口技术、编程方法。

51单片机实现的多图显示用12864液晶驱动程序设计

51单片机实现的多图显示用12864液晶驱动程序设计

51单片机实现的多图显示用12864液晶驱动程序设计作者:佚名日期:2010年06月02日来源:不详【字体:大中小】我要评论(0)核心提示:/************************************************程序名称:12864液晶驱动程序(显示多图)简要说明:控制器:KS0107 LCD型号:FM12864、TS12864A-2或兼容型号(不带字库)&nbs/************************************************程序名称:12864液晶驱动程序(显示多图)简要说明:控制器:KS0107LCD型号:FM12864、TS12864A-2或兼容型号(不带字库)MCU:AT89S5*,晶体频率:11.0592MHz取模方式:纵向取模、字节倒序CS1和CS2为高电平有效************************************************/;***************硬件端口定义***********RS EQU P2.0RW EQU P2.1E EQU P2.2CS1 EQU P2.3CS2 EQU P2.4RST EQU P2.5COM EQU 20H ;指令数据寄存器DAT EQU 21H ;显示数据寄存器;**********************************主程序入口地址ORG 0000HAJMP STRORG 0003H;*********************************中断程序入口地址STR:AJMP L0100L0100: CLR RSTNOPNOPSETB RST;********************************以上是软件复位MOV SP,#60HMOV IE,#81H ;中断允许MOV IP,#01H ;优先中断MOV TCON,#00H ;电平中断MOV COM,#3FH ;显示开LCALL S02A9 ;左半屏写指令子程序LCALL S02C1 ;右半屏写指令子程序;----------------------------------------------------------------------MOV COM,#0C0H ;第一行LCALL S02A9 ;左半屏写指令子程序LCALL S02C1 ;右半屏写指令子程序;----------------------------------------------------------------------MOV COM,#0B8H ;第一页LCALL S02A9 ;左半屏写指令子程序LCALL S02C1 ;右半屏写指令子程序;----------------------------------------------------------------------MOV COM,#40H ;第一列LCALL S02A9 ;左半屏写指令子程序LCALL S02C1 ;右半屏写指令子程序;********************************************************以上是软件初始化MOV B,#0AAHLCALL XIHX ;显示横线1LCALL DELAY; MOV B,#55H; LCALL XIHX; LCALL DELAY ;显示横线2MOV B,#0FFHMOV 29H,#00HLCALL XISXLCALL DELAY ;显示竖线1; MOV B,#00H; MOV 29H,#0FFH; LCALL XISX; LCALL DELAY ;显示竖线2MOV DPTR,#TAB1LCALL LEFTMOV DPTR,#TAB2LCALL RIGHTLCALL DELAY ;显示第一幅图片MOV DPTR,#TAB3LCALL LEFTMOV DPTR,#TAB4LCALL RIGHTLCALL DELAY ;显示第二幅图片MOV DPTR,#TAB5LCALL LEFTMOV DPTR,#TAB6LCALL RIGHTLCALL DELAY ;显示第三幅图片AJMP L0100;=======================================================以上是主程序LEFT: MOV R1,#0B8H_AB: MOV COM,R1 ;第一页LCALL S02A9 ;左半屏写指令子程序MOV COM,#40H ;第一列LCALL S02A9 ;左半屏写指令子程序MOV R0, #64S027B: MOV A,#00HMOVC A,@A+DPTRMOV DAT,ALCALL S02B1 ;左半屏写数据子程序INC DPTRDJNZ R0,S027BINC R1CJNE R1, #0C0H,_ABRET;======================================================以上是左半屏写数据子程序RIGHT: MOV R1,#0B8HABC: MOV COM,R1 ;第一页LCALL S02C1 ;右半屏写指令子程序MOV COM,#40H ;第一列LCALL S02C1 ;右半屏写指令子程序MOV R0, #64S027D: MOV A,#00HMOVC A,@A+DPTRMOV DAT,ALCALL S02B9 ;右半屏写数据子程序INC DPTRDJNZ R0,S027DINC R1CJNE R1, #0C0H,ABCRET;*******************************************************以上是右半屏写数据子程序XIHX: MOV R1,#0B8HBA: MOV COM,R1 ;第一页LCALL S02A9 ;左半屏写指令子程序LCALL S02C1 ;右半屏写指令子程序MOV COM,#40H ;第一列LCALL S02A9 ;左半屏写指令子程序LCALL S02C1 ;右半屏写指令子程序MOV R0, #64W027B: MOV DAT,BLCALL S02B1 ;左半屏写数据子程序LCALL S02B9 ;右半屏写数据子程序DJNZ R0,W027BINC R1CJNE R1, #0C0H,BARET;---------------------------------------------------------XISX: MOV R1,#0B8HCA: MOV COM,R1 ;第一页LCALL S02A9 ;左半屏写指令子程序LCALL S02C1 ;右半屏写指令子程序MOV COM,#40H ;第一列LCALL S02A9 ;左半屏写指令子程序LCALL S02C1 ;右半屏写指令子程序MOV R0, #32X027B: MOV DAT,BLCALL S02B1 ;左半屏写数据子程序LCALL S02B9 ;右半屏写数据子程序MOV DAT,29HLCALL S02B1 ;左半屏写数据子程序LCALL S02B9 ;右半屏写数据子程序DJNZ R0,X027BINC R1CJNE R1, #0C0H,CARET;****************************************************以上是显示线条程序S02A9: SETB CS1LCALL S02C9CLR CS1 ;左半屏写指令子程序RETS02B1: SETB CS1 ;左半屏写数据子程序LCALL S02E0CLR CS1RETS02C1: SETB CS2 ;右半屏写指令子程序LCALL S02C9CLR CS2RETS02B9: SETB CS2 ;右半屏写数据子程序LCALL S02E0CLR CS2RET;****************************************************S02C9: CLR RSSETB RWS02C9A: MOV P0,#0FFHSETB EMOV A, P0CLR EJB ACC.7,S02C9ACLR RWMOV P0,COMSETB ENOPCLR ERET;*************************************************以上是写指令子程序S02E0: CLR RSSETB RWS02E0A: MOV P0,#0FFHSETB EMOV A, P0CLR EJB ACC.7,S02E0ASETB RSCLR RWMOV P0,DATSETB ENOPCLR ERET;************************************************以上是写数据子程序DELAY: MOV R5,#0BH ;延时D1: MOV R7,#0FFHD2: MOV R6,#0FFHD3: DJNZ R6,$DJNZ R7,D2DJNZ R5,D1RET;****************************************************************TAB1:;-- 调入了一幅图像:C\128x64-1.bmp --;-- 宽度x高度=64x64 --DB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,080H,080H,0C0H,0C0 HDB0E0H,0E0H,0E0H,0F0H,0F0H,0F0H,0F0H,0F0H,0F8H,0F8H,0F8H,0F8H,0F8H,0F8H,0F8H,0F 8HDB0FCH,0FCH,0FCH,0FCH,0FCH,0FCH,0FCH,0FCH,0FCH,0FCH,07CH,078H,078H,038H,038H ,030HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,000H,000H,0E0H,0F0H,0FCH,0FEH,0FFH,0FFH,0FFH,0FFH,0F FHDB0FFH,0FFH,0FFH,0FFH,0EFH,0CFH,0E7H,0E7H,0E7H,0F3H,073H,033H,03BH,019H,00DH,0 8DHDB0CDH,0E7H,0F6H,0FEH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,07FH,03EH,01CH, 000HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,0E0H,0E0H,0F0H,0F0H,0F0H,0F8H,0F9H,0FDH,0FDH,0FDH,0DFH,09FH,08EH,08FH,0 8FHDB08FH,00FH,00FH,00FH,00FH,00FH,007H,003H,001H,060H,060H,06CH,06CH,06EH,06FH,06 7HDB067H,0E7H,0F7H,0F7H,0F3H,0F3H,0F3H,0F3H,0F9H,0F9H,0F8H,0F8H,0FCH,0FCH,0FEH,0 FEHDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,001H,00FH,07FH,0FFH,0FFH,0FFH,0FFH,0FFH,07FH,01FH,00FH,007H,003H,003H,00 1HDB081H,0E0H,0F0H,0F8H,0FCH,0FEH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FEH,0FEH,0FEH, 0FEHDB0FEH,0FCH,0FCH,0FCH,0F8H,0F0H,061H,001H,001H,003H,003H,007H,0DFH,0FFH,0FFH,0 FFHDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,001H,00FH,07FH,0FFH,0FFH,0E0H,0C0H,0C0H,080H,000H,000H,00 0HDB003H,007H,00FH,00FH,00FH,00FH,00FH,00FH,00FH,00FH,00FH,00FH,00FH,00FH,00FH,00 7HDB087H,087H,0C3H,0C3H,0C1H,0E0H,0F0H,0F0H,0F8H,0FCH,0FCH,0FFH,0FFH,0FFH,0FFH, 0FFHDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,000H,000H,001H,00FH,07FH,0FFH,0FFH,0FFH,0FFH,0FFH,0F FHDB0FEH,0FEH,0FEH,0FEH,0FEH,0FEH,0FEH,0FEH,0FEH,0FEH,0FEH,0FEH,0FFH,0FFH,0FFH ,0FFHDB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,07FH,07FH,03FH,03FH,03FH,01FH,01FH,01FH,0 0FHDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,003H,00FH,07FH,0FFH,0FFH,0FF HDB0FFH,07FH,07FH,03FH,03FH,03FH,01FH,01FH,01FH,00FH,00FH,00FH,007H,007H,003H,00 3HDB003H,001H,001H,001H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HTAB2:;-- 调入了一幅图像:C:\128x64-2.bmp --;-- 宽度x高度=64x64 --DB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,080H,080H,080H,0C0 HDB0C0H,0C0H,0E0H,0E0H,0E0H,0F0H,0F0H,0F8H,0F8H,0F8H,0FCH,0FCH,0FCH,0FEH,0FEH, 0FFHDB0FFH,0FFH,0FFH,0FEH,0F8H,0C0H,000H,000H,000H,000H,000H,000H,000H,000H,000H,00 0HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB030H,038H,078H,0F8H,0FCH,0FCH,0FCH,0FEH,0FEH,0FEH,0FFH,0FFH,0FFH,0FFH,0FFH, 0FFHDB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, 0FFHDB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FEH,0F0H,0C0H,000H,000H,000H,000H,000H,000H,00 0HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,080H,0C0H,0F1H,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0 FFHDB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, 0FFHDB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FEH,0F0H,080H,000H,000H,000H,0 00HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,03FH,007H,001H,001H,001H,001H,00 1HDB0E1H,0FDH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,01FH,007H,001H,001H,001H,0C1H,0 C1HDB001H,001H,001H,007H,01FH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FEH,0F0H,080H,00 0HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,03FH,007H,001H,000H,000H,000H,000H,0E0H,0F8H,0F FHDB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,03FH,007H,000H,000H,000H,000H,038H,03EH,03FH,0B FHDB0BFH,0F8H,0C0H,0C0H,0E0H,0E0H,0E7H,0FFH,0FFH,09FH,01FH,00FH,00FH,007H,007H,0 00HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB0FFH,0FFH,0FFH,0FFH,0EFH,0E1H,0E0H,0E0H,0E0H,0E0H,0E0H,0F8H,07FH,07FH,07FH,0 3FHDB03FH,03FH,07FH,07FH,07FH,078H,07CH,07CH,07CH,07EH,00EH,007H,003H,003H,003H,00 3HDB003H,003H,003H,00FH,03FH,07FH,07FH,07FH,07FH,07FH,07CH,070H,000H,000H,000H,00 0HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB00FH,00FH,007H,007H,003H,003H,003H,001H,001H,001H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HTAB3:;-- 调入趣味性文字和图片像右半屏:纵向取模下高位,数据排列:从左到右从上;-- 宽度x高度=64x64 --DB000H,000H,000H,000H,000H,000H,000H,000H,000H,0E0H,0C0H,080H,0C0H,0F8H,0F0H,0B 0HDB060H,068H,0D0H,0F0H,0F0H,020H,020H,060H,0C0H,0C0H,0C0H,0C0H,080H,080H,080H,00 0HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,0C0H,0F0H,0FCH,0EFH,0F3H,0F9H,0FCH,0F1H,07BH,07DH,0 3FHDB03EH,038H,03EH,03CH,03DH,038H,03FH,03FH,03EH,03EH,03FH,03FH,03FH,03FH,07FH,0 7FHDB0FFH,0FEH,0FEH,0FCH,0F8H,0F0H,0E0H,080H,000H,000H,000H,000H,000H,000H,000H,00 0HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,0E0H,0FEH,0FFH,0FFH,0FFH,07FH,007H,001H,000H,000H,008H,008H,00 8HDB010H,010H,020H,040H,000H,000H,000H,000H,000H,040H,020H,010H,010H,008H,008H,008 HDB000H,000H,001H,007H,03FH,0FFH,0FFH,0FFH,0FEH,0E0H,000H,000H,000H,000H,000H,00 0HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,080H,09FH,0FFH,0FFH,063H,061H,0E0H,0E0H,0F0H,0F0H,0F0H,0F0H,0D0H,08 0HDB010H,010H,020H,020H,0C0H,060H,060H,060H,0C0H,0E0H,0E0H,0F0H,0F0H,0F0H,0F0H,0D 0HDB010H,010H,010H,020H,0E0H,060H,061H,0FFH,0FFH,09FH,080H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB006H,009H,010H,010H,020H,039H,060H,080H,001H,003H,007H,007H,007H,007H,007H,007 HDB007H,004H,004H,022H,041H,040H,040H,040H,041H,023H,007H,007H,007H,007H,007H,007 HDB007H,004H,004H,002H,001H,080H,060H,039H,020H,010H,010H,019H,0E6H,000H,004H,000 HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,080H,0C0H,0C0H,0E1H,0E2H,0E2H,0F4H,0F4H,0F4H,0F8H,0F 8HDB0F8H,0F0H,0F0H,0F0H,090H,090H,090H,090H,090H,070H,0F0H,0F0H,0E8H,0E8H,0E8H,0C 4HDB0C4H,084H,082H,002H,0FBH,0F4H,0E4H,0F4H,0FCH,004H,002H,001H,000H,000H,000H,00 0HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,007H,00FH,01FH,03FH,03FH,07FH,07FH,0FFH,021H,001H,003H,007 HDB00FH,09FH,0FFH,0FFH,0FFH,0FEH,0F9H,0F7H,0FEH,0F8H,0FFH,0FFH,0FFH,0FFH,0FFH,0 E7HDB00FH,00FH,01FH,01FH,03FH,03FH,03FH,03FH,01FH,000H,000H,000H,000H,000H,000H,00 0HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H,002H,004H,004H,004 HDB002H,001H,00FH,03FH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0 FFHDB0FFH,0FCH,0F0H,060H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HTAB4:;-- 调入了一幅图像:帅呆了吧DB000H,000H,0E0H,000H,0F8H,000H,0E0H,020H,0F8H,020H,020H,0E0H,000H,000H,000H,078 HDB048H,048H,0C8H,048H,048H,078H,000H,000H,000H,000H,008H,008H,008H,008H,0C8H,048 HDB028H,018H,008H,000H,000H,0F0H,010H,0F0H,000H,0F0H,010H,010H,0F0H,010H,0F8H,010 HDB000H,000H,000H,000H,000H,000H,000H,000H,0E0H,0F0H,0F0H,0E0H,000H,000H,000H,000 HDB000H,020H,017H,008H,007H,000H,00FH,000H,03FH,000H,008H,00FH,000H,021H,011H,009 HDB005H,003H,03FH,003H,005H,009H,011H,011H,000H,000H,000H,000H,020H,020H,03FH,000 HDB000H,000H,000H,000H,000H,007H,004H,007H,000H,01FH,021H,021H,021H,021H,021H,038 HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,01BH,01BH,000H,000H,000H,000H,000 HDB000H,0F4H,05CH,034H,05CH,0F4H,000H,05CH,048H,07EH,048H,048H,000H,040H,05EH,0D 4HDB054H,054H,040H,0DEH,054H,054H,052H,058H,000H,000H,002H,002H,002H,002H,0F2H,012DB00AH,006H,002H,000H,000H,0FCH,084H,084H,0FCH,000H,03AH,022H,0A2H,0FEH,022H,02 2HDB000H,000H,000H,000H,000H,000H,000H,000H,038H,0FCH,0FCH,038H,000H,000H,000H,000 HDB000H,00FH,005H,005H,005H,00FH,000H,00FH,009H,009H,009H,00FH,000H,00AH,009H,00B HDB005H,003H,000H,00FH,00AH,009H,009H,00EH,000H,000H,000H,000H,008H,008H,00FH,000 HDB000H,000H,000H,000H,000H,001H,000H,008H,009H,004H,002H,009H,008H,00FH,000H,000 HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,006H,006H,000H,000H,000H,000H,000 HDB000H,018H,0FFH,008H,050H,044H,044H,0FFH,044H,044H,07CH,040H,000H,020H,022H,02 AHDB0B2H,062H,0FFH,062H,0B2H,02AH,022H,020H,000H,004H,004H,0FFH,004H,004H,0FCH,00 0HDB0FCH,004H,004H,0FCH,000H,000H,000H,000H,0C1H,031H,00EH,030H,0C0H,000H,000H,00 0HDB000H,000H,000H,07CH,055H,056H,0FCH,056H,055H,054H,07CH,000H,000H,000H,000H,00 0HDB000H,000H,007H,0C4H,004H,002H,001H,0C0H,001H,002H,004H,004H,000H,002H,002H,0C 1HDB000H,000H,087H,080H,080H,0C1H,082H,002H,000H,004H,003H,080H,044H,004H,003H,000 HDB0C7H,002H,002H,007H,000H,004H,082H,001H,000H,0C0H,000H,000H,000H,0C1H,002H,00 4HDB000H,001H,001H,0C1H,041H,041H,0C7H,041H,041H,041H,0C1H,001H,000H,000H,000H,00DB000H,000H,080H,07FH,012H,012H,012H,013H,0F2H,002H,002H,002H,000H,061H,019H,0FF HDB009H,091H,07FH,000H,000H,0FFH,000H,0C0H,000H,0FFH,091H,091H,091H,0FFH,004H,00 BHDB031H,001H,001H,0FFH,000H,002H,0FFH,002H,002H,07FH,022H,022H,022H,07FH,002H,002 HDB000H,020H,020H,017H,08DH,075H,007H,005H,0FDH,015H,027H,020H,000H,000H,000H,000 HDB000H,001H,000H,000H,000H,000H,000H,000H,001H,000H,000H,000H,000H,000H,000H,001 HDB001H,000H,000H,000H,000H,001H,001H,001H,000H,001H,000H,000H,000H,001H,000H,000 HDB001H,001H,001H,000H,000H,000H,001H,001H,001H,001H,001H,001H,001H,001H,001H,001 HDB000H,000H,001H,001H,000H,000H,000H,000H,001H,000H,000H,000H,000H,000H,000H,000 HTAB5:;-- 调入图像:纵向取模下高位,数据排列:从左到右从上到下;-- 宽度x高度=64x64 --DB000H,000H,000H,000H,000H,000H,000H,000H,000H,0C0H,0E0H,0E0H,0F0H,0F0H,0F0H,0F 0HDB0F0H,0F0H,0F8H,0BCH,01CH,08CH,0CEH,0CFH,0CFH,0EBH,0C9H,0D0H,090H,010H,010H, 010HDB020H,021H,061H,041H,043H,0C2H,08CH,000H,001H,001H,002H,006H,00CH,00FH,010H,03 EHDB023H,046H,085H,089H,019H,033H,066H,08DH,0DBH,0F9H,0A6H,02FH,03FH,007H,08FH,0C FHDB000H,000H,000H,080H,0E0H,0F0H,0F0H,0F0H,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0 FFHDB0FFH,07FH,0FFH,0EFH,0FFH,0FFH,0FFH,0FFH,07FH,06FH,037H,01BH,00FH,007H,001H,0 0FHDB009H,00AH,00EH,006H,006H,004H,004H,00CH,008H,018H,010H,020H,060H,040H,0C0H,08 0HDB000H,000H,000H,001H,0C3H,007H,00DH,037H,022H,0C2H,083H,001H,00FH,037H,01FH,03 7HDB000H,000H,000H,0FFH,0FFH,0FFH,0FFH,01FH,006H,0C6H,0E6H,066H,07EH,0FFH,0EFH,0 D1HDB0D9H,0E9H,0E9H,0F9H,0F2H,0E6H,01CH,030H,000H,000H,000H,000H,000H,000H,000H,00 0HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001 HDB003H,0C6H,078H,0B0H,0E0H,083H,00EH,018H,0E0H,080H,003H,00EH,038H,0C0H,018H,0F 0HDB000H,000H,000H,000H,007H,00FH,01FH,01FH,01CH,0FFH,07FH,060H,038H,027H,079H,0C 1HDB0F3H,0F3H,0FFH,0FFH,078H,03FH,002H,000H,000H,000H,000H,000H,000H,000H,002H,071 HDB039H,019H,0F9H,0F9H,0F9H,0FBH,0FBH,073H,073H,0E6H,0CEH,09CH,038H,030H,000H,0 00HDB000H,01FH,0E0H,0FFH,0FFH,0FFH,0FCH,0F8H,0E0H,087H,0F8H,000H,000H,007H,0FEH,0 F1HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,07FH,0C0H,000H,000H,000H,000H,000 HDB080H,000H,000H,010H,010H,000H,020H,020H,020H,000H,000H,000H,000H,000H,01CH,03E HDB070H,07CH,07CH,078H,0FFH,0FFH,07FH,07EH,03EH,01FH,003H,003H,002H,000H,000H,00 0HDB000H,000H,000H,0FBH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,000H,000H,000H,0FFH,0 F3HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,003H,018H,0E0H,000H,000H,000 HDB003H,006H,00EH,00EH,00EH,018H,018H,018H,008H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,080 HDB0C0H,0C6H,0EFH,0A7H,073H,07BH,009H,084H,0CCH,0E3H,0FFH,0F8H,0FCH,0FEH,0FFH, 0FFHDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,002H,006 HDB000H,00CH,008H,008H,000H,010H,010H,010H,010H,010H,018H,018H,008H,084H,084H,004 HDB006H,0F2H,0B2H,016H,034H,0E4H,004H,004H,004H,00CH,0CCH,08CH,01CH,018H,03FH,0 3FHDB07CH,0DEH,0DFH,0DFH,0EEH,0F7H,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, 0FFHDB000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000 HDB000H,000H,000H,000H,000H,000H,000H,004H,004H,00EH,036H,064H,07CH,018H,001H,003 HDB00EH,000H,001H,001H,003H,001H,000H,000H,000H,000H,003H,003H,003H,001H,000H,000 HDB000H,000H,001H,007H,00FH,03FH,07FH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0 FFHTAB6:;-- 调入图像:纵向取模下高位,数据排列:从左到右从上到下;-- 宽度x高度=64x64;-- 调入了一幅图像:我们年轻.bmp --;-- 宽度x高度=64x64 --DB000h,000h,000h,000h,000h,000h,000h,000h,080h,080h,000h,0C0h,000h,080h,000h,000h DB000h,000h,000h,000h,000h,0C0h,000h,040h,080h,000h,080h,080h,080h,000h,000h,000h DB000h,000h,0C0h,000h,000h,000h,000h,000h,000h,000h,080h,000h,000h,000h,000h,000h DB0C0h,000h,000h,000h,080h,080h,080h,080h,080h,000h,000h,000h,000h,000h,000h,000h DB000h,000h,000h,044h,044h,045h,025h,0FFh,014h,014h,084h,07Fh,0C4h,024h,015h,084h DB000h,000h,008h,004h,0FFh,000h,0FFh,000h,000h,000h,000h,000h,0FFh,000h,000h,000h DB044h,042h,079h,049h,049h,049h,0FFh,049h,049h,049h,049h,041h,000h,000h,089h,08Fh DB049h,0FDh,029h,001h,028h,024h,0E2h,023h,024h,008h,000h,000h,000h,000h,000h,000h DB000h,000h,000h,080h,080h,088h,0B2h,003h,020h,0A1h,028h,030h,020h,0E1h,022h,023h DB000h,000h,080h,040h,03Bh,020h,023h,020h,0E0h,020h,020h,022h,033h,020h,000h,000h DB020h,0E0h,038h,0A0h,020h,020h,013h,090h,050h,070h,090h,000h,000h,000h,020h,0A0h DB0A8h,0B3h,0A0h,0A2h,082h,0FAh,083h,092h,0A2h,082h,000h,000h,000h,000h,000h,000h DB000h,000h,000h,000h,040h,020h,01Fh,020h,050h,048h,045h,042h,045h,048h,050h,040h DB000h,000h,008h,008h,00Fh,009h,009h,009h,07Fh,009h,009h,009h,009h,008h,000h,000h DB011h,011h,009h,07Fh,005h,040h,045h,044h,07Ch,044h,044h,041h,000h,000h,020h,01Bh DB042h,07Eh,00Ah,053h,020h,01Fh,000h,07Fh,040h,070h,000h,000h,000h,000h,000h,000h DB000h,000h,000h,000h,040h,040h,040h,05Fh,055h,055h,0D5h,055h,05Fh,040h,040h,040h DB000h,000h,010h,011h,0F6h,000h,000h,0FCh,056h,055h,054h,05Eh,0C4h,000h,000h,000h DB010h,0D4h,014h,0FFh,094h,094h,022h,022h,0FEh,022h,022h,020h,000h,000h,008h,008hDB008h,008h,0C8h,03Fh,048h,088h,008h,008h,00Ch,008h,000h,000h,000h,000h,000h,000hDB000h,000h,000h,000h,000h,0C8h,044h,043h,0C4h,008h,0CFh,049h,049h,049h,0E9h,048h DB000h,000h,008h,084h,0C3h,0A4h,088h,00Bh,00Ah,0EAh,08Ah,08Ah,08Bh,008h,000h,000h DB08Ch,003h,004h,0E7h,008h,008h,008h,0E8h,00Bh,008h,008h,008h,000h,000h,048h,044hDB042h,041h,040h,041h,046h,040h,041h,042h,06Ch,044h,000h,000h,000h,000h,000h,000hDB000h,000h,000h,000h,000h,0FFh,022h,025h,018h,000h,0FFh,044h,044h,044h,0FFh,000hDB000h,000h,000h,0FFh,088h,088h,0FFh,002h,005h,018h,080h,000h,0FFh,000h,000h,000hDB020h,013h,008h,0FFh,002h,002h,002h,0FFh,002h,002h,002h,002h,000h,000h,000h,0FFhDB009h,011h,0FFh,000h,000h,0FFh,009h,011h,0FFh,000h,000h,000h,000h,000h,000h,000hDB 000h,000h,000h,000h,000h,001h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h DB 000h,000h,000h,001h,000h,000h,001h,000h,000h,000h,000h,001h,000h,000h,000h,000h DB 000h,000h,000h,001h,000h,001h,001h,001h,001h,001h,001h,000h,000h,000h,000h,001h DB 000h,001h,001h,000h,000h,001h,000h,001h,001h,000h,000h,000h,000h,000h,000h,000h END上传两个显示画面液晶屏是朋友托卖的,无背光无字库,带负压产生电路,有些成色比较新,先到先得了,45RMB一块,送资料,驱动程序,QQ以下是程序//**************************************;* 控制器:KS0107 *;* LCD型号:TS12864A-2或兼容型号 *;* MCU:AT89S5* ,晶体频率:11.0592MHz *;* 取模方式:纵向字节倒序 *;* CS1和CS2为高电平有效 * *;***************硬件端口定义***********RS EQU P2.4RW EQU P2.3E EQU P2.2CS1 EQU P2.7CS2 EQU P2.6RST EQU P2.5BUF EQU P0;******************************************COM EQU 20H ;指令数据寄存器DAT EQU 21H ;显示数据寄存器;**********************************主程序入口地址ORG 0000HAJMP STRORG 0003H;*********************************中断程序入口地址STR:AJMP L0100L0100: CLR RSTNOPNOPSETB RST;********************************以上是软件复位MOV SP,#60HMOV IE,#81H ;中断允许MOV IP,#01H ;优先中断MOV TCON,#00H ;电平中断MOV COM,#3FH ;显示开LCALL S02A9 ;左半屏写指令子程序LCALL S02C1 ;右半屏写指令子程序;---------------------------------------------------------------------- MOV COM,#0C0H ;第一行LCALL S02A9 ;左半屏写指令子程序LCALL S02C1 ;右半屏写指令子程序;---------------------------------------------------------------------- MOV COM,#0B8H ;第一页LCALL S02A9 ;左半屏写指令子程序LCALL S02C1 ;右半屏写指令子程序;---------------------------------------------------------------------- MOV COM,#40H ;第一列LCALL S02A9 ;左半屏写指令子程序LCALL S02C1 ;右半屏写指令子程序;********************************************************以上是软件初始化MOV B,#0AAHLCALL XIHX ;显示横线1LCALL DELAYMOV B,#55HLCALL XIHXLCALL DELAY ;显示横线2MOV B,#0FFHMOV 29H,#00HLCALL XISXLCALL DELAY ;显示竖线1MOV B,#00HMOV 29H,#0FFHLCALL XISXLCALL DELAY ;显示竖线2MOV DPTR,#TAB1LCALL LEFTMOV DPTR,#TAB2LCALL RIGHTLCALL DELAY ;显示第一幅图片MOV DPTR,#TAB3LCALL LEFTMOV DPTR,#TAB4LCALL RIGHTLCALL DELAY ;显示第二幅图片MOV DPTR,#TAB5LCALL LEFTMOV DPTR,#TAB6LCALL RIGHTLCALL DELAY ;显示第三幅图片AJMP L0100;=======================================================以上是主程序LEFT: MOV R1,#0B8H_AB: MOV COM,R1 ;第一页LCALL S02A9 ;左半屏写指令子程序MOV COM,#40H ;第一列LCALL S02A9 ;左半屏写指令子程序MOV R0, #64S027B: MOV A,#00HMOVC A,@A+DPTRMOV DAT,ALCALL S02B1 ;左半屏写数据子程序INC DPTRDJNZ R0,S027BINC R1CJNE R1, #0C0H,_ABRET;======================================================以上是左半屏写数据子程序RIGHT: MOV R1,#0B8HABC: MOV COM,R1 ;第一页LCALL S02C1 ;右半屏写指令子程序MOV COM,#40H ;第一列LCALL S02C1 ;右半屏写指令子程序MOV R0, #64S027D: MOV A,#00HMOVC A,@A+DPTRMOV DAT,ALCALL S02B9 ;右半屏写数据子程序INC DPTRDJNZ R0,S027DINC R1CJNE R1, #0C0H,ABCRET;*******************************************************以上是右半屏写数据子程序XIHX: MOV R1,#0B8HBA: MOV COM,R1 ;第一页LCALL S02A9 ;左半屏写指令子程序LCALL S02C1 ;右半屏写指令子程序MOV COM,#40H ;第一列LCALL S02A9 ;左半屏写指令子程序LCALL S02C1 ;右半屏写指令子程序MOV R0, #64W027B: MOV DAT,BLCALL S02B1 ;左半屏写数据子程序LCALL S02B9 ;右半屏写数据子程序DJNZ R0,W027BINC R1CJNE R1, #0C0H,BARET;--------------------------------------------------------- XISX: MOV R1,#0B8HCA: MOV COM,R1 ;第一页LCALL S02A9 ;左半屏写指令子程序LCALL S02C1 ;右半屏写指令子程序MOV COM,#40H ;第一列LCALL S02A9 ;左半屏写指令子程序LCALL S02C1 ;右半屏写指令子程序MOV R0, #32X027B: MOV DAT,BLCALL S02B1 ;左半屏写数据子程序LCALL S02B9 ;右半屏写数据子程序MOV DAT,29HLCALL S02B1 ;左半屏写数据子程序LCALL S02B9 ;右半屏写数据子程序DJNZ R0,X027BINC R1CJNE R1, #0C0H,CARET;****************************************************以上是显示线条程序S02A9: SETB CS1LCALL S02C9CLR CS1 ;左半屏写指令子程序RETS02B1: SETB CS1 ;左半屏写数据子程序LCALL S02E0CLR CS1RETS02C1: SETB CS2 ;右半屏写指令子程序LCALL S02C9CLR CS2RETS02B9: SETB CS2 ;右半屏写数据子程序LCALL S02E0CLR CS2RET;****************************************************S02C9: CLR RSSETB RWS02C9A: MOV BUF,#0FFHSETB EMOV A, BUFCLR EJB ACC.7,S02C9ACLR RWMOV BUF,COMSETB ENOPCLR ERET;*************************************************以上是写指令子程序S02E0: CLR RSSETB RWS02E0A: MOV BUF,#0FFHSETB EMOV A, BUFCLR EJB ACC.7,S02E0ASETB RSCLR RWMOV BUF,DATSETB ENOPCLR ERET;************************************************以上是写数据子程序DELAY: MOV R5,#0BH ;延时D1: MOV R7,#0FFHD2: MOV R6,#0FFHD3: DJNZ R6,$DJNZ R7,D2DJNZ R5,D1RET;****************************************************************TAB1:;-- 调入菲戈幅图像左半屏:纵向取模下高位,数据排列:从左到右从上到下;-- 宽度x高度=64x64DB000h,000h,000h,040h,080h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,010h DB060h,080h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,0FCh,000h,000h DB000h,000h,000h,000h,000h,000h,000h,000h,000h,0C0h,030h,008h,000h,000h,000h,000h DB000h,000h,000h,000h,000h,080h,040h,000h,000h,000h,000h,000h,000h,000h,000h,000h DB000h,000h,000h,000h,000h,001h,002h,004h,008h,010h,020h,040h,080h,000h,000h,000h DB000h,001h,006h,018h,060h,080h,000h,000h,000h,000h,000h,000h,000h,0FFh,000h,000h DB000h,000h,000h,000h,000h,0C0h,030h,00Ch,003h,000h,000h,000h,000h,080h,040h,020h DB010h,008h,004h,002h,001h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h DB002h,002h,004h,004h,008h,008h,010h,010h,020h,020h,040h,040h,080h,081h,002h,004h DB008h,010h,020h,040h,080h,001h,006h,018h,020h,000h,000h,000h,080h,09Fh,080h,000h DB000h,040h,030h,00Ch,003h,080h,040h,020h,010h,008h,004h,002h,001h,000h,000h,080h DB080h,040h,040h,020h,020h,010h,010h,010h,008h,008h,004h,004h,002h,002h,000h,000h000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,001h,001h DB002h,002h,004h,004h,008h,009h,000h,030h,0CCh,002h,001h,001h,000h,000h,000h,001h DB001h,002h,0CCh,030h,001h,000h,008h,008h,004h,004h,002h,002h,001h,001h,001h,000h DB000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h DB000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,004h,018h DB060h,080h,000h,000h,000h,000h,000h,000h,000h,001h,002h,002h,084h,0FCh,044h,042h DB022h,021h,020h,020h,010h,010h,010h,060h,080h,000h,000h,000h,000h,000h,000h,000h DB000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h DB000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h DB000h,000h,003h,004h,004h,002h,002h,002h,001h,001h,001h,001h,000h,0FFh,000h,000h DB000h,000h,000h,000h,000h,000h,000h,000h,000h,001h,006h,008h,010h,000h,000h,000h DB000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h DB000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h DB000h,000h,080h,080h,040h,040h,020h,020h,010h,010h,008h,008h,004h,00Fh,010h,020h。

51单片机12864液晶字符显示

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点阵液晶显示模块与51单片机的并行接口电路及C51程序设计

中文图形12864点阵液晶显示模块与51单片机的并行接口电路及C51程序设计

BF 位 ! 当 BF 为 0 时 !LM3033B *0BR3 才可接收 新的指令或数据 " 在操作时 !LM3033B+0BR3 在单
片机的时钟信号的控制下 ! 数据通过数据线传送给
LM3033B,0BR3 ! 当 LM3033B-0BR3 成功接收 到数据后 ! 转入内部时钟控制 ! 封 锁 I/O 口 缓 冲 器 !
技 术 交 流

! 结论
在单片机与液晶的接口中 ! 关键是要满足液晶 的时序要求 * 在软件编程中 ! 关键是要进行正确的初 始化 + 操作及写入显示内容的代码 $ 以上接口电路和 相应的程序已经通过调试 ! 并在实际中得到应用 $ 由
& 2008’ 07- 0041- 04 文章编号 "1006- 6268
中文图形 12864 点阵液晶显示模块与 51 单片机的并行接口电路及 C51 程序设计
李志广 :J;! 李晓泉 L! 淮俊霞 :J; &:Q 河北工业大学应用物理系 ! 天津 L$$:L$%
技 术 交 流
;Q深圳市拓普微科技开发有限公司 ! 深圳 D:<$DX% LQ天津市轻工业设计院 ! 天津 L$$:YL ’
[1]杨应平 , 石城 , 蒋爱湘 , 李振华 . 图形点阵液晶显示 模块与 51 系列单片机的接口设计 [J ]. 现代显示 ! 2006,(5):41- 45. [2]李良成 , 张永顺 , 张璟 . 基于 MSP430 单片机的液
晶显示[J ]. 现代显示 !2007 !(5):32- 33.
其对应关系如表图形显示绘图显示ram提供64x32个位元组的记忆空由扩充指令设定绘图ram位址在更改绘图ram时由扩充指令设定gdram位址先设置垂直位址再设置水平位址连续写入两个位元组的资料来完成垂直与水平的坐标位址再写入两个资料到绘图ram而位址计数器ac会自动加一整个写入绘图ram的步骤如下

C8051F单片机与RT12864M液晶显示模块接口设计

C8051F单片机与RT12864M液晶显示模块接口设计

C8051F单片机与RT12864M液晶显示模块接口设计陈建权,丁彦闯大连交通大学机械工程学院,辽宁大连(116028)E-mail:chenjq409@摘要:介绍了RT12864M带汉字库的液晶显示模块与C8051F020单片机的两种接口方式。

分析了在5V系统中C8051Fxxx的电平转换原理,给出了硬件原理图以及用C语言实现读写该模块的部分程序。

RT12864M液晶显示模块内部自带汉字库,能显示图形、汉字,可以广泛的应用于各种仪器仪表开发。

关键词:单片机,RT12864M,电平转换,Keil C51中图分类号:TN709 文献标识码:B1. 引言在智能仪器仪表的开发中,为了实现良好的操作界面,通常要有人机交互的显示界面。

液晶显示模块具有低功耗等特点,广泛的应用于各种数字仪表。

由于液晶显示是一种慢速器件,因此如何控制读写时序在显示过程中显得十分重要。

RT12864M液晶显示模块是一款图形液晶显示器,它主要由行驱动/列驱动和128*64点阵液晶显示器组成,可完成图形显示,也可显示8*4个(16*16点阵)汉字。

内置8192个中文汉字(16X16点阵)、128个字符(8X16点阵)及64X256点阵显示RAM(GDRAM)[1]。

C8051F单片机是美国cygnal公司生产的51系列单片机增强型单片机,它内部硬件采用流水指令译码,实现了指令单周期执行。

此外,内部自带了一定1k到8k不等的RAM 以及4k~128k的FLASH ROM,广泛应用于各种仪器仪表开发。

本文分析了C8051F单片机与RT12864 LCM的工作特点,给出了C8051F单片机与RT12864M LCM 的显示接口,并给出了实现显示的部分程序。

2. RT12864引脚及指令介绍RT12864M引脚如表一所示。

RT12864M液晶显示模块有11条基本指令集以及7条扩充指令集组成。

下面交要介绍几条常用的指令。

CODE1: 功能:清除显示屏幕,把DDRAM地址计数器调整为“00H”。

12864串口C51程序

12864串口C51程序
for(i=0; i <n; i++) {;}
}
//串行发送一字节数据
void SendByte(unsigned ch
for(i=0;i <8;i++)
sbit RW_SID=P3^1;//data input/output 串行数据输入、输出端
//sbit RS_CS =P3^5;//chip select 片选端
// SendCMD(0x0F);//显示设定,开显示,显示光标,当前显示位反白闪动
}
void main(void)
{
initlcm();
SendCMD(0x81);//1000,0001 设定DDRAM 7位地址000,0001到地址计数器AC
delay(100);
display(0x90,0xb0,0xb2);//安
display(0x91,0xbb,0xD5);//徽
display(0x92,0xb5,0xe7);//电
display(0x93,0xc1,0xA6);//力
display(0x94,0xc5,0xe0);//培
display(0x95,0xD1,0xb5);//训
display(0x8B,0xc1,0xA6);//力
display(0x8C,0xc5,0xe0);//培
display(0x8D,0xD1,0xb5);//训
//sbit PSB =P3^6;//serial mode select 串口模式
sbit RST =P1^2;
void delay(unsigned int n)
{
unsigned int i;

液晶屏12864的51单片机程序

液晶屏12864的51单片机程序

void Port_Init (void)
{
// XBR0 = 0x01;
// UART0 Selected
XBR1 = 0x40;
// Enable crossbar and weak pull-ups
P0MDOUT |= 0xDf;
// TX, LEDs = Push-pull
Crossbar
P1MDOUT |=0x03; }
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters : None
//
// This function initializes the GPIO and the
// its lowest frequency
RSTSRC = 0x04;
// Enable missing clock detector
}
//-----------------------------------------------------------------------------
// Port_Init
void WriteDataLCM(uchar dataW) {
LCM_EN=0; LCM_RS=1; DataPort&=0xf0; DataPort|=(dataW&0xf0)>>4; delay(1); LCM_EN=1; delay(1); LCM_EN=0; delay(1); DataPort&=0xf0; DataPort|=(dataW&0x0f); delay(1); LCM_EN=1; delay(1); LCM_EN=0; }

用51单片机做的万年历,显示用12864液晶

用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);}。

51单片机带字库12864液晶动态汉字显示C语言源程序

51单片机带字库12864液晶动态汉字显示C语言源程序

51单片机带字库12864液晶动态汉字显示C语言源程序2009-10-17 19:36实验芯片为:AT89S52,带字库液晶屏:12864,实现的目的:动态一个汉字一个汉字显示。

其实和显示汉字的程序一样,只是稍做一下修改即可。

C语言源程序如下:#include <stdio.h>#include <math.h>#include <reg52.h>#include <string.h>sbit RS=P2^4;sbit WRD=P2^5;sbit E=P2^6;sbit PSB=P2^1;sbit RES=P2^3;void TransferData(char data1,bit DI);void delayms(unsigned int n);void delay(unsigned int m);void lcd_mesg003(unsigned char code *addr1);unsigned char code IC_DAT[]={"我是一个中国人啊"};void initinal(void){delay(40);PSB=1; //并口工作模式delay(1);RES=0; //复位delay(1);RES=1; //复位置高delay(10);TransferData(0x30,0);delay(100);TransferData(0x30,0);delay(37);TransferData(0x08,0);delay(100);TransferData(0x10,0);delay(100);TransferData(0x0C,0);delay(100);TransferData(0x01,0);delay(10);TransferData(0x06,0);delay(100);}void main(void){while(1){initinal();//调用LCD字库初始化程序delay(100);lcd_mesg003(IC_DAT);}}void lcd_mesg003(unsigned char code *addr1){unsigned char i;//第一行TransferData(0x80,0);delay(100);for(i=0;i<16;i++){TransferData(*addr1,1);addr1++;delayms(50);}}void TransferData(char data1,bit DI) //传送数据或是命令,当DI=0时,传送命令,当DI=1时,传送数据{WRD=0;RS=DI;delay(1);P0=data1;E=1;delay(1);E=0;}void delayms(unsigned int n){unsigned int i,j;for(i=0;i<n;i++)for(j=0;j<2000;j++);}void delay(unsigned int m){unsigned int i,j;for(i=0;i<m;i++)for(j=0;j<10;j++);}原理就是在显示每个汉字的时候加了一个延时程序,当然可以用定时器来实现,这样的话,不占用CPU处理时间。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
{
writLCD(0,lineyou[lines]);//写入显示所在地址,writ address! display which line
AUTO(add);// writ data dispaly what(*add)
}
void init()
{
delay(10);
writLCD(0,0x01);
writLCD(0,0x02);
writLCD(0,0x06);
writLCD(0,0x0f);
// writLCD(0,0x30);//CGRAM o ACC自己编写的字符
writLCD(0,0x80); //DDRAMto ACC(字符显示RAM缓冲区)
}
void main()
{
init();
delay(1);
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
#define lcdbus P0
sbit rs=P2^0;
sbit rw=P2^1;
sbit en=P2^2;
uchar code line[5]={0x00,0x80,0x90,0x88,0x98};
//writLCD(0,0x01);
wirtthings(4,"什么,only You!");
//writLCD(0,0x01);
wirtthings(1,"联系方式:");
//writLCD(0,0x01);
wirtthings(2,"QQ:452658536");
delay(100);
writLCD(0,0x01);
else
RW=0;
delay(10);
SCK=1;
DATA=DATA<<1;
}
}
void writLCD(bit flag,uchar DATA) //writ COM or data in address
{
if(flag)
sent(0xfa);//1写数据
else
sent(0xf8);//0写指令
}
}
sent(DATA&0XF0); //先写高位后写低位
sent((DATA&0X0F)<<4); //低位
}
void AUTO(uchar *add)
{
uchar cnt=0;
while(*(add+cnt)!='\0')
{
writLCD(1,*(add+cnt));
cnt++;
}
}
void wirtthings(uchar lines,uchar *add)//writ data to which line
{
writ_DATCOM(0,line[flagline]);
AUTO_line(address);
}
void init()
{
writ_DATCOM(0,0x01);
writ_DATCOM(0,0x02);
writ_DAபைடு நூலகம்COM(0,0x0c);
writ_DATCOM(0,0x30);
writ_DATCOM(0,0x80);
void delay(uchar i)
{
uchar j;
while(i--)
for(j=0;j<125;j++);
}
void writ_DATCOM(bit flagdc,uchar thing)
{
rs=flagdc;
rw=0;
delay(1);
lcdbus=thing;
en=1;//en为高数据写入,0为低停止写入
void delay(uchar i)
{
uchar j;
while(i--)
for(j=0;j<125;j++);
}
void sent(uchar DATA)//byte1
{
uchar i;
for(i=0;i<8;i++)
{
SCK=0;
if(DATA&0x80)//高位先出、1000 0000
RW=1;
wirtthings(2,"什么,only You!");
wirtthings(3,"我也不知道我在想");
wirtthings(4,"什么,什么该想··");
while(1)
{
writLCD(0,0x06);//4、5右到左1 I/D S 6,左到右
wirtthings(3,"没有人知道我在想");//87
}
void main()
{
init();
writline(1,"广西职业技术学院");
writline(2,"电气自动化——技术");
writline(3,"QQ:452658536");
writline(4,"学号: 09232017");
while(1);
}
//////////////////////////////////////////////////////
以下是12864串口连接程序
/**** 12864串口*******/
//QQ:462658536
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit RW=P2^1;
sbit SCK=P2^2;
uchar code lineyou[5]={0x00,0x80,0x90,0x88,0x98} ;//code
delay(15);//数据写入的速度
en=0;
}
void AUTO_line(uchar *data_add)
{
uchar cnt;
while(*(cnt+data_add)!='\0')
{
writ_DATCOM(1,*(cnt+data_add));
cnt++;
}
}
void writline(uchar flagline,uchar *address)
相关文档
最新文档