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液晶显示程序(串口)

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液晶操作

点阵12864液晶操作

点阵LCD12864的显示原理(不带字库)在数字电路中,所有的数据都是以0和1保存的,对LCD控制器进行不同的数据操作,可以得到不同的结果。

对于显示英文操作,由于英文字母种类很少,只需要8位(一字节)即可。

而对于中文,常用却有6000以上,于是我们的D OS前辈想了一个办法,就是将ASCII表的高128个很少用到的数值以两个为一组来表示汉字,即汉字的内码。

而剩下的低128位则留给英文字符使用,即英文的内码。

那么,得到了汉字的内码后,还仅是一组数字,那又如何在屏幕上去显示呢?这就涉及到文字的字模,字模虽然也是一组数字,但它的意义却与数字的意义有了根本的变化,它是用数字的各位信息来记载英文或汉字的形状,如英文的'A'在字模的记载方式如图1所示:图1 “A”字模图而中文的“你”在字模中的记载却如图2所示:图2 “你”字模图12864点阵型LCD简介12864是一种图形点阵液晶显示器,它主要由行驱动器/列驱动器及128×64全点阵液晶显示器组成。

可完成图形显示,也可以显示8×4个(16×16点阵)汉字。

管脚号管脚名称LEVER 管脚功能描述1 VSS 0 电源地2 VDD +5.0V 电源电压3 V0 - 液晶显示器驱动电压4 D/I(RS) H/L D/I=“H”,表示DB7∽DB0为显示数据D/I=“L”,表示DB7∽DB0为显示指令数据5 R/W H/L R/W=“H”,E=“H”数据被读到DB7∽DB0R/W=“L”,E=“H→L”数据被写到IR或DR6 E H/L R/W=“L”,E信号下降沿锁存DB7∽DB0R/W=“H”,E=“H”DDRAM数据读到DB7∽DB07 DB0 H/L 数据线8 DB1 H/L 数据线9 DB2 H/L 数据线10 DB3 H/L 数据线11 DB4 H/L 数据线12 DB5 H/L 数据线13 DB6 H/L 数据线14 DB7 H/L 数据线15 CS1 H/L H:选择芯片(右半屏)信号16 CS2 H/L H:选择芯片(左半屏)信号17 RET H/L 复位信号,低电平复位18 VOUT -10V LCD驱动负电压19 LED+ - LED背光板电源20 LED- - LED背光板电源表1:12864LCD的引脚说明在使用12864LCD前先必须了解以下功能器件才能进行编程。

12864液晶显示源程序(方法2)

12864液晶显示源程序(方法2)

main函数:*****12864显示********//***作者:曹江*****//*****时间:2008 8 25 ********/#include<Lcd.h>#include<absacc.h>#include "AT89X51.h"//函数名:main() 主函数//函数参数:无//返回值:无void main(){reset(); //调用复位函数dison_off(1); //开lcd显示set_startline(0); // 从第0行开始从上至下滑动显示clear(); //清屏while(1){display();}}lcd.c子函数:#include "AT89X51.h"#include "Lcd.h"#include "data.h"#define uint unsigned int//函数名:delay() 延时函数//函数参数:uint v//返回值:无void delay(uint v){ uint i;while(v!=0){v--;for(i=125;i>0;i--);}}//函数名:busy_check() 检测忙状态左//函数参数:无//返回值:无void busy_check(void){unsigned char busy;while(busy&0x80){busy=0xff;}}//函数名:reset()复位函数//函数参数:无//返回值:无void reset(){P3_2=0; //接lcd复位端口RSTdelay(1);P3_2=1;delay(1);}//函数名:wcode(c,cs1,cs2)写指令函数//函数参数:uchar c, uchar cs1,uchar cs2//返回值:无void wcode(ucharc,uchar cs1,uchar cs2){busy_check();P3_4=cs1;P3_3=cs2;P3_7=0; //接lcd的rs端P3_6=0; //接lcd的rw端P1=c; //lcd数据端d0-d7P3_5=0; //接lcd的e端delay(5);P3_5=1;delay(5);P3_5=0;}//函数名:wdata(c,cs1,cs2)写数据函数//函数参数:uchar c, uchar cs1,uchar cs2//返回值:无void wdata(ucharc,uchar cs1,uchar cs2){busy_check();P3_4=cs1;P3_3=cs2;P3_7=1;P3_6=0;P1=c;P3_5=0;delay(1);P3_5=1;delay(1);P3_5=0;}//函数名:set_startline(i)设置起始行函数//函数参数:uchar i//返回值:无void set_startline(uchar i)//每次加一使其从第0行开始从上至下滑动显示{i=0xc0+i;wcode(i,0,0); //调用写指令函数}//函数名:set_adr(x,y)设置页值,起始列值函数//函数参数:uchar x,uchar y//返回值:无void set_adr(uchar x ,uchar y){x=x+0xb8; //X位址即页page起始0xb8y=y+0x40; //Y位址即列起始0x40wcode(x,0,0);//调用写函数wcode(y,0,0);}//函数名:dison_off(uint o)开关显示函数//函数参数:uint o//返回值:无void dison_off(uchar o){o=o+0x3e;wcode(o,0,0);}//函数名:clear() 清屏函数//函数参数:无//返回值:无void clear(){uchari,loop;for(i=0;i<8;i++){set_adr(i,0);for(loop=0;loop<64;loop++)wdata(0x00,0,0); //左右半屏同时写0}}//函数名:chinese(x,y,n,cs1,cs2) 汉字函数//函数参数:x,y,n,cs1,cs2 注:x,y为页和列号;n为字号;cs1,cs2为左右屏显示//返回值:无void chinese(ucharx,uchary,ucharn,uchar cs1,uchar cs2){ uchari,loop;for(i=0;i<2;i++){set_adr(x+i,y);//一字分上下两页写for(loop=0;loop<16;loop++){wdata(Chinese_Charcter[n][16*i+loop],cs1,cs2);}}}//函数名:display() 显示函数//函数参数:无//返回值:无void display(){uchar i;for(i=0;i<0xff;i++) //汉字上下滚屏显示{set_startline(i);chinese(0,32,0,1,0); //第0行第1个字“长”,屏左边显示chinese(0,48,1,1,0); //第0行第2个字“江”,屏左边显示chinese(0,0,2,0,1); //第0行第3个字“大”,屏右边显示chinese(0,16,3,0,1); //第0行第4个字“学”,屏右边显示chinese(2,16,4,1,0); //第1行第5个字“电”,屏左边显示chinese(2,32,5,1,0); //第1行第5个字“子”,屏左边显示chinese(2,48,6,1,0); //第1行第6个字“信”,屏左边显示chinese(2,0,7,0,1); //第1行第5个字“息”,屏右边显示chinese(2,16,8,0,1); //第1行第7个字“学”,屏右边显示chinese(2,32,9,0,1); //第1行第8个字“院”,屏右边显示chinese(4,32,10,1,0); //第2行第9个字“电”,屏左边显示chinese(4,48,11,1,0); //第2行第10个字“气”,屏左边显示chinese(4,0,12,0,1); //第2行第11个字“工”,屏右边显示chinese(4,16,13,0,1); //第2行第12个字“程”,屏右边显示chinese(4,32,14,0,1); //第2行第13个字“系”,屏右边显示chinese(6,48,15,1,0); //第6行第21个字“曹”,屏左边显示chinese(6,0,16,0,1); //第6行第22个字“江”,屏右边显示delay(10);i+=5;}}data.h:#ifndef _DATA_H_#define _DATA_H_//**********显示文字部分*********////左右分屏写,同页同行内按左到右顺序写extern uchar code Chinese_Charcter[25][32]={{/*-- 文字: 长--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x80,0x80,0x80,0x80,0xFF,0xA0,0xA0,0x90,0x90,0x88,0x84,0x82,0x80,0x80,0x80,0x00, 0x00,0x00,0x00,0x00,0xFF,0x40,0x21,0x12,0x04,0x08,0x10,0x30,0x60,0x20,0x00,0x00, },{/*-- 文字: 江--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x60,0x01,0xC6,0x30,0x00,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x00,0x00, 0x04,0x04,0x7E,0x01,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x00, },{/*-- 文字: 大--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/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, },{/*-- 文字: 学--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/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, },{/*-- 文字: 电--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0xF8,0x48,0x48,0x48,0x48,0xFF,0x48,0x48,0x48,0x48,0xF8,0x00,0x00,0x00, 0x00,0x00,0x0F,0x04,0x04,0x04,0x04,0x3F,0x44,0x44,0x44,0x44,0x4F,0x40,0x70,0x00, },{/*-- 文字: 子--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x02,0x02,0x02,0x02,0x02,0xE2,0x12,0x0A,0x06,0x02,0x00,0x80,0x00,0x00, 0x01,0x01,0x01,0x01,0x01,0x41,0x81,0x7F,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00, },{/*-- 文字: 信--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x80,0x40,0x30,0xFC,0x07,0x0A,0xA8,0xA8,0xA9,0xAE,0xAA,0xA8,0xA8,0x08,0x08,0x00, 0x00,0x00,0x00,0x7F,0x00,0x00,0x7E,0x22,0x22,0x22,0x22,0x22,0x7E,0x00,0x00,0x00, },{/*-- 文字: 息--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x00,0xFC,0x54,0x54,0x56,0x55,0x54,0x54,0x54,0xFC,0x00,0x00,0x00,0x00, 0x00,0x20,0x38,0x01,0x3D,0x41,0x41,0x45,0x59,0x41,0x41,0x71,0x00,0x08,0x30,0x00, },{/*-- 文字: 学--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/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, },{/*-- 文字: 院--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/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, },{/*-- 文字: 电--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0xF8,0x48,0x48,0x48,0x48,0xFF,0x48,0x48,0x48,0x48,0xF8,0x00,0x00,0x00, 0x00,0x00,0x0F,0x04,0x04,0x04,0x04,0x3F,0x44,0x44,0x44,0x44,0x4F,0x40,0x70,0x00, },{/*-- 文字: 气--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x20,0x10,0x8C,0xA7,0xA4,0xA4,0xA4,0xA4,0xA4,0xA4,0xA4,0x24,0x04,0x04,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x30,0x40,0xF0,0x00, },{/*-- 文字: 工--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x02,0x02,0x02,0x02,0x02,0xFE,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00, },{/*-- 文字: 程--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x12,0xD2,0xFE,0x91,0x11,0x80,0xBF,0xA1,0xA1,0xA1,0xA1,0xBF,0x80,0x00,0x00, 0x04,0x03,0x00,0xFF,0x00,0x41,0x44,0x44,0x44,0x7F,0x44,0x44,0x44,0x44,0x40,0x00, },{/*-- 文字: 系--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x02,0x22,0xB2,0xAA,0x66,0x62,0x22,0x11,0x4D,0x81,0x01,0x01,0x00,0x00, 0x00,0x40,0x21,0x13,0x09,0x05,0x41,0x81,0x7F,0x01,0x05,0x09,0x13,0x62,0x00,0x00, },{/*-- 文字: 曹--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x02,0x02,0xFA,0xAA,0xAA,0xAA,0xFF,0xAA,0xAA,0xFF,0xAA,0xAA,0xAA,0xFA,0x02,0x00, 0x00,0x00,0x00,0x7E,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x7E,0x00,0x00,0x00, },{/*-- 文字: 江--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x60,0x01,0xC6,0x30,0x00,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x00,0x00, 0x04,0x04,0x7E,0x01,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x00, },};#endif仿真效果图:。

无字库12864液晶屏滚动显示程序共17页文档

无字库12864液晶屏滚动显示程序共17页文档

无字库12864液晶屏滚动显示程序[转] #include<reg52.h>#include<intrins.h>#include<absacc.h>#define Lcd_Bus P0 //MCU P0<------> LCM#define Disp_On 0x3f//开显示#define Disp_Off 0x3e//关显示#define Col_Add 0x40//列地址#define Page_Add 0xb8//页地址#define Start_Line 0xc0//起始页sbit cs1=P2^3; //Master chip enablesbit cs2=P2^4; //Slave chip enablesbit Enable=P2^2; // mode Enable singlesbit Di=P2^0; //Data or Instrument Selectsbit RW=P2^1; //Write or Readsbit Lcd_Rst=P2^5; //Lcm reset/*****************************字模,此字体下对应的点阵为:宽x高=16x16*****************************/unsigned char code Chinese_character[][32]={{0x02,0xF2,0x12,0x12,0x12,0xFE,0x12,0x12,0x12,0xFE,0x12,0x12,0x 12,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,0x 94,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,0x 7C,0x10,0x10,0x00,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,0x 04,0x04,0x04,0x00,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,0x FF,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,0x C8,0x48,0x08,0x00,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,0x 20,0x20,0x20,0x00,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,0x 57,0x32,0x10,0x00,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,0x 30,0xE0,0x40,0x00,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,0x 20,0x60,0x20,0x00,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,0x 02,0x02,0x00,0x00,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,0x BF,0x80,0x00,0x00,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,0x 57,0x32,0x10,0x00,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,0x 24,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,0x 10,0x10,0x10,0x00,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,0x FF,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,0x 08,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,0x 02,0x02,0x00,0x00,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,0x 02,0x02,0x00,0x00,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,0x BF,0x80,0x00,0x00,0x04,0x03,0x00,0xFF,0x00,0x41,0x44,0x44,0x44,0x7F,0x44 ,0x44,0x44,0x44,0x40,0x00},/*"程",5*/};unsigned char code E[][16]={{0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00},/*"C",0*/{0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x 20,0x00,0x01,0x00},/*"r",1*/{0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x 22,0x22,0x3F,0x20},/*"a",2*/{0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x 24,0x24,0x19,0x00},/*"s",3*/{0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x 18,0x06,0x01,0x00},/*"y",4*/{0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x 20,0x11,0x0E,0x00},/*"b",5*/{0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x 20,0x20,0x1F,0x00},/*"o",6*/{0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x 18,0x06,0x01,0x00},/*"y",7*/{0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x 22,0x22,0x13,0x00},/*"e",8*/};/***********************延时子程序***********************/ void delay(unsigned int k){unsigned int i;unsigned int j;for(i=0;i<k;i++)for(j=0;j<20;j++);}/***********************写命令左***********************/ void write_cmd_1(unsigned char command){cs1=1;cs2=0;Di=0;RW=0;Lcd_Bus=command; //P0口delay(0);Enable=1;delay(0);Enable=0;}/***********************写命令右***********************/ void write_cmd_2(unsigned char command){cs1=0;cs2=1;Di=0;RW=0;Lcd_Bus=command;delay(0);Enable=1;delay(0);Enable=0;}/***********************写数据左***********************/ void write_data_1(unsigned char dis_data){cs1=1;cs2=0;Di=1;RW=0;Lcd_Bus=dis_data;delay(0);Enable=1;delay(0);Enable=0;}/***********************写数据右***********************/ void write_data_2(unsigned char dis_data){cs1=0;cs2=1;Di=1;RW=0;Lcd_Bus=dis_data;delay(0);Enable=1;delay(0);Enable=0;}/***********************清内存左***********************/ void clear_1(void){unsigned char j,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);}}/***********************清内存右***********************/ void clear_2(void){unsigned char j,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左************************/void Chinese_disp_1(unsigned char pag,unsigned char col,unsigned char n){unsigned char i=0;unsigned char j=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右***********************/ void Chinese_disp_2(unsigned char pag,unsigned char col,unsigned char n){unsigned char i=0;unsigned char j=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左************************/ void E_disp_1(unsigned char pag,unsigned char col,unsigned char n) {unsigned char i=0;unsigned char j=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右***********************/ void E_disp_2(unsigned char pag,unsigned char col,unsigned char n) {unsigned char i=0;unsigned char j=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]);}}/***********************液晶屏初始化***********************/ void init_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显示子程序***********************/ void display(void){unsigned char i;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);}/***********主程序************/ void main(void){ init_lcd();clear_1();clear_2();while(1){display();}}希望以上资料对你有所帮助,附励志名言3条:1、宁可辛苦一阵子,不要苦一辈子。

12864液晶显示程序

12864液晶显示程序
void lcd_wcmd(uchar command,uchar wait_en)
{
if(wait_en) //若wait_en为1,则要检测LCD忙信号
lcd_busy();
PORTC &=~(1<<LCD_RS);
PORTC &=~(1<<LCD_RW);
This program was produced by the
CodeWizardAVR V2.04.4a Advanced
Automatic Program Generator
?Copyright 1998-2009 Pavel Haiduc, HP InfoTech s.r.l.

**********************************************************/
void lcd_init(void)
{ DDRB=0XFF; //设置PA输出 PORTB=0XFF; //全部加上上拉电阻
DDRC=0XFF; //设置PC为输出
PORTC=0XFF; //全部加上上拉电阻
delay_ms(30); //等待上电稳定
PORTC|=(1<<LCD_PSB); //并口方式
PORTC &=~(1<<LCD_RST); //液晶复位
{X=0x80;}
else if (X==2) //第二行
{X=0x90;}
else if (X==3) //第三行
{X=0x88;}
else if (X==4) //第四行
{X=0x98;}
PORTC |=(1<<LCD_EN);

51单片机 12864液晶显示程序

51单片机 12864液晶显示程序

/*========================LCD12864液晶并行驱动程序==========================程序名称:12864液晶驱动程序(并行模式)================================================= ===========================*/#include <at89x52.h>#define uchar unsigned char#define uint unsigned intuchar t,p;/********************************引脚定义***********************************/#define RS P1_0 //RS=0为执行指令;RS=1为执行数据;#define RW P1_1 //读写#define E P1_2 //使能#define PSB P1_3 //低电平(串口驱动);高电平(并口驱动)#define RST P1_4 //LCD复位/********************************定义数组***********************************/uchar code title[] = {"LCD 并行接口测试"}; uchar code website[]={"qwertyuioopplkjh"}; uchar code dig[]={"0123456789"};uchar code dig2[]={0,1,2,3,':'}; ///*******************************相关子程序**********************************/void Init_lcd(); //初始化液晶void lcd_busy(); //忙标志查询void delay100us(); //100us延时程序void write(uchar x,uchar Data); //写单字节函数void Show(uchar address,uchar L,uchar STR1[]); void Show_dig(uchar address,uint number);/*******************************延时子程序**********************************/void delay100(int n){unsigned char i;while(n--)for(i=0;i<100;i++);}/*******************************LCD 忙标志查询******************************/void lcd_busy(void){uchar busy;P0=0xff;RS=0;RW=1;do{E=1;busy=P0;E=0;}while(busy>0x7f);}/*****************************写指令或数据**********************************/void write(uchar x,uchar Data){lcd_busy(); //忙查询if(x==0){RS=0;RW=0; //写单字节命令字}else if(x==1){RS=1;RW=0; //写单字节数据}E=1;P0=Data;E=0;P0=0xff;}/*******************************初始化LCD **********************************/void Init_lcd(void){delay100(20); //启动等待,等LCM讲入工作状态PSB=1; //并口驱动模式RST=0;delay100(4);RST=1; // 复位LCDwrite(0,0x30); //8 位介面,基本指令集write(0,0x0c); //显示打开,光标关,反白关write(0,0x01); //清屏,将DDRAM的地址计数器归零}/*******汉字和字符显示,参数入口:Show(地址,显示宽度,汉字数组)************/void Show(uchar address,uchar L,uchar STR1[]) {uchar i;write(0,address);for(i=0;i<L;i++)write(1,STR1[i]);}/************纯阿拉伯数字显示,参数入口:Show_dig (地址,数字)**************/void Show_dig(uchar address,uint number){uchar shi,ge;shi=number/10;ge=number%10;write(0,address);delay100(20);write(1,dig[shi]);delay100(20);write(1,dig[ge]);}/************************************主程序**********************************/void main(void){Init_lcd();TMOD=0X01;TH0=0xdc;TL0=0x00;ET0=1;TR0=1;EA=1;P3_6=0;delay100(30);Show(0x83,4,"梁浩"); //写数组里的容write(0,0x0d);delay100(30);Show(0x90,16,"电子科技协会会长"); delay100(30);Show(0x88,16,"TEL "); //写英文delay100(30);while(1){Show_dig(0x99,p); //写实时数组}}void exter() interrupt 1{TH0=0xdc;TL0=0x00;t++;if(t==20){t=0;p++;}if(p==60)p=0;}/***************************************end****** *****************************/。

LCD12864(不带字库)

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点阵)汉字。

在使用12864LCD前先必须了解以下功能器件才能进行编程。

12864内部功能器件及相关功能如下:1. 指令寄存器(IR)IR是用于寄存指令码,与数据寄存器数据相对应。

当D/I=0时,在E信号下降沿的作用下,指令码写入IR。

2.数据寄存器(DR)DR是用于寄存数据的,与指令寄存器寄存指令相对应。

当D/I=1时,在下降沿作用下,图形显示数据写入DR,或在E信号高电平作用下由DR读到DB7∽DB0数据总线。

DR和DDRAM之间的数据传输是模块内部自动执行的。

3.忙标志:BFBF标志提供内部工作情况。

BF=1表示模块在内部操作,此时模块不接受外部指令和数据。

BF=0时,模块为准备状态,随时可接受外部指令和数据。

利用STATUS READ指令,可以将BF读到DB7总线,从检验模块之工作状态。

无字库LCD12864(无时钟芯片显示时间)

无字库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;}}。

12864LCD液晶显示屏程序(南京航空航天大学金城学院)

12864LCD液晶显示屏程序(南京航空航天大学金城学院)

附:实验箱程序#include<reg52.h>#include<ABSACC.H>typedef unsigned char uchar;typedef unsigned int uint;#define LLCD_CMD_WR XBYTE[0xfe04] //地址需根据实际情况计算改变(下同)#define LLCD_CMD_RD XBYTE[0xfe06]#define LLCD_DATA_WR XBYTE[0xfe05]#define LLCD_DATA_RD XBYTE[0xfe07]#define RLCD_CMD_WR XBYTE[0xfe00]#define RLCD_CMD_RD XBYTE[0xfe02]#define RLCD_DATA_WR XBYTE[0xfe01]#define RLCD_DATA_RD XBYTE[0xfe03]sbit busy=P0^7;code uchar hanzil[]={0x08,0x64,0x23,0xA6,0xAA,0xA2,0xAA,0xB4,0xA3,0xA2,0xA6,0x2A,0x22,0x62,0x20,0x00,0x00,0x00,0x00,0xFF,0x4A,0x4A,0x4A,0x4A,0x4A,0x4A,0x4B,0xF8,0x00,0x00,0x00,0x00,/*"管",0*/0x42,0x42,0xFE,0x42,0x42,0x00,0x40,0x5E,0x50,0xD0,0x5F,0x50,0x50,0x5E,0x40,0x00,0x10,0x10,0x0F,0x08,0x04,0x00,0xFF,0x01,0x01,0x7F,0x01,0x3F,0x41,0x81,0x7F,0x00,/*"瑞",1*/0x00,0x00,0x60,0x50,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x98,0xF0,0x70,0x00,0x00,0x00,0x00,0x20,0x30,0x28,0x28,0x24,0x24,0x22,0x22,0x21,0x20,0x30,0x18,0x00,0x00,/*"2",0*/0x00,0x00,0x00,0x60,0x90,0x08,0x08,0x10,0x20,0x10,0x08,0x08,0x90,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x08,0x04,0x02,0x01,0x00,0x00,0x00,0x00,/*"心",0*/0x00,0x00,0x00,0x60,0x90,0x08,0x08,0x10,0x20,0x10,0x08,0x08,0x90,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x08,0x04,0x02,0x01,0x00,0x00,0x00,0x00,/*"心",0*/0x00,0xE0,0xF0,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x18,0x10,0xF0,0xC0,0x00,0x00,0x00,0x00,0x11,0x33,0x22,0x22,0x22,0x22,0x22,0x32,0x11,0x1D,0x0F,0x03,0x00,0x00,/*"9",3*/0x00,0x00,0x00,0x60,0x90,0x08,0x08,0x10,0x20,0x10,0x08,0x08,0x90,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x08,0x04,0x02,0x01,0x00,0x00,0x00,0x00,/*"心",0*/0x00,0x00,0x30,0x30,0x08,0x08,0x88,0x88,0x88,0x88,0x58,0x70,0x30,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x20,0x20,0x20,0x20,0x20,0x20,0x31,0x11,0x1F,0x0E,0x00,0x00,/*"3",5*/0x00,0x00,0x30,0x30,0x08,0x08,0x88,0x88,0x88,0x88,0x58,0x70,0x30,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x20,0x20,0x20,0x20,0x20,0x20,0x31,0x11,0x1F,0x0E,0x00,0x00,/*"3",6*/0x00,0x00,0x60,0x50,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x98,0xF0,0x70,0x00,0x00,0x00,0x00,0x20,0x30,0x28,0x28,0x24,0x24,0x22,0x22,0x21,0x20,0x30,0x18,0x00,0x00,/*"2",7*/0x00,0x00,0x60,0x50,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x98,0xF0,0x70,0x00,0x00,0x00,0x00,0x20,0x30,0x28,0x28,0x24,0x24,0x22,0x22,0x21,0x20,0x30,0x18,0x00,0x00,/*"2",8*/0x00,0x00,0x30,0x30,0x08,0x08,0x88,0x88,0x88,0x88,0x58,0x70,0x30,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x20,0x20,0x20,0x20,0x20,0x20,0x31,0x11,0x1F,0x0E,0x00,0x00,/*"3",9*/0x00,0x00,0x20,0x10,0x08,0x10,0x20,0x00,0x00,0x20,0x10,0x08,0x10,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x04,0x08,0x08,0x04,0x02,0x00,0x00,0x00,0x00,0x00,/*"未命名文件",0*/};void lcd_cmd_wr(uchar cmdcode,uchar right);void lcd_data_wr(uchar ldata,uchar right);void lcd_busy_rd(uchar right);void lcd_hanzi_wr(uchar posx,uchar posy,uchar *hanzi);void lcd_str_wr(uchar row,uchar col,uchar n,uchar *str);void lcd_rol();void lcd_init();void delay(uint nms);void main(){lcd_init();lcd_str_wr(1,1,13,hanzil); //起始行、列、汉字长度delay(100);while(1){lcd_rol();delay(1000);}}void lcd_cmd_wr(uchar cmdcode,uchar right) {lcd_busy_rd(right);if(right==1){ RLCD_CMD_WR=cmdcode; }else{ LLCD_CMD_WR=cmdcode; }}void lcd_data_wr(uchar ldata,uchar right) {lcd_busy_rd(right);if(right==1){RLCD_DATA_WR=ldata;}else{LLCD_DATA_WR=ldata;}}void lcd_busy_rd(uchar right){if(right==0)RLCD_CMD_RD;elseLLCD_CMD_RD;}void delay(uint nms){uint i;for(;nms>0;nms--)for(i=0;i<500;i++);}void lcd_init(void) //LCD初始化子程序{uint k,m;lcd_cmd_wr(0x3e+1,0);lcd_cmd_wr(0xc0+0,0);lcd_cmd_wr(0xb8+0,0);lcd_cmd_wr(0x40+0,0);lcd_cmd_wr(0x3e+1,1);lcd_cmd_wr(0xc0+0,1);lcd_cmd_wr(0x40+0,1);lcd_cmd_wr(0xb8+0,1);for(k=0;k<8;k++) //页循环{for(m=0;m<64;m++) //列循环{lcd_data_wr(0x00,0);lcd_data_wr(0x00,1);}lcd_cmd_wr(0xb8+k+1,0);lcd_cmd_wr(0x40+0,0);lcd_cmd_wr(0xb8+k+1,1);lcd_cmd_wr(0x40+0,1);}}void lcd_hanzi_wr(uchar posx,uchar posy,uchar*hanzi) //显示汉字子程序{uchar i;if(posy<4) //左半屏{lcd_cmd_wr(0xb8+2*posx,0);lcd_cmd_wr(0x40+16*posy,0);for(i=0;i<16;i++){lcd_data_wr(hanzi[i],0);}lcd_cmd_wr(0xb8+2*posx+1,0);lcd_cmd_wr(0x40+16*posy,0);for(i=16;i<32;i++){lcd_data_wr(hanzi[i],0);}}else //右半屏{lcd_cmd_wr(0xb8+posx*2,1);lcd_cmd_wr(0x40+16*(posy-4),1);for(i=0;i<16;i++){lcd_data_wr(hanzi[i],1);}lcd_cmd_wr(0xb8+2*posx+1,1);lcd_cmd_wr(0x40+16*(posy-4),1);for(i=16;i<32;i++){lcd_data_wr(hanzi[i],1);}}}void lcd_str_wr(uchar row,uchar col,uchar n,uchar*str) {uchar i;for(i=0;i<n;i++){if(col>7){row++;col=col-8;}lcd_hanzi_wr(row,col,str+i*32);col++;}}void lcd_rol(void) //滚动上移子程序{uchar i;for(i=0;i<64;i++){lcd_cmd_wr(0xc0+i,0);lcd_cmd_wr(0xc0+i,1);delay(10);}}PROTEUS仿真实验现象。

12864显示程序

12864显示程序
void Conversion(uint temp_data)
{
Wan=temp_data/10000+0x30 ;
temp_data=temp_data%10000;
Qian=temp_data/1000+0x30 ;
temp_data=temp_data%1000;
Delay5us();
ADXL345_SCL = 0;
Delay5us();
}
ADXL345_RecvACK();
}
/**************************************
{
ADXL345_SDA = 1;
ADXL345_SCL = 1;
Delay5us();
ADXL345_SDA = 0;
Delay5us();
}
void ADXL345_SendACK(bit ack)
{
ADXL345_SDA = ack;
ADXL345_SCL = 1;
Delay5us();
void ADXL345_Single_Write(uchar REG_Address,uchar REG_data)
{
ADXL345_Start();
ADXL345_SendByte(SlaveAddress);
ADXL345_SendByte(REG_Address);
#include<reg52.h>
#include<intrins.h>
#include<math.h>
#include<stdio.h>

多种12864液晶屏显示程序

多种12864液晶屏显示程序

多种12864液晶屏显示程序(1)#include#define uchar unsigned char#define uint unsigned int#define lcddata P0sbit RS=P2^0;sbit RW=P2^1;sbit E=P2^2;sbit PSB=P2^3;void delayms(uint n)//1T单片机毫秒延时函数{ unsigned int x;while(n--){x=627;while(x--);}}void delayus(uint t)//1T单片机微秒延时函数{ unsigned int a,b;for(b=t;b>0;b--)for(a=3;a>0;a--);}bit lcdbusy() //忙检查{bit result;RS=0;RW=1;E=1;delayus(5);result=(bit)(P0&0x80);E=0;return(result) ;}void writecmd(uchar cmd) //写命令{while(lcdbusy()) ;RS=0;RW=0;E=0;delayus(5);P0=cmd;delayus(10);E=1;delayus(5);E=0;}void writedat(uchar dat) //写数据{while(lcdbusy()) ;RS=1;RW=0;E=0;delayus(5);P0=dat;delayus(10);E=1;delayus(5);E=0;}void print(uchar place,uchar num,uchar *point)//液晶屏显示数组{uchar i,progdata;writecmd(place);for(i=0;i<="">{progdata=*(point+i);writedat(progdata);}}void lcdclear(){unsigned char i;writecmd(0x30);writecmd(0x80);writecmd(0x01);delayus(20);for(i=0;i<64;i++)writedat(' ');}void lcdinit()//液晶屏初始化{PSB=1;//并口方式writecmd(0x30);//基本指令操作delayms(5);writecmd(0x06);//写一个字符后地址指针自动加1 delayms(5);writecmd(0x0c);//开显示,关光标delayms(5);writecmd(0x01);//清屏指令delayms(5);}void main(){lcdinit();print(0x80,3,"战斗机");//起始位,显示汉字数print(0x85,3,"巡洋舰");print(0x8a,4,"航空母舰");while(1);}(2)#include#define uchar unsigned char#define uint unsigned int#define lcddata P0sbit RS=P2^0;sbit RW=P2^1;sbit E=P2^2;sbit PSB=P2^3;void delayms(uint n)//1T单片机毫秒延时函数{ unsigned int x;while(n--){x=627;while(x--);}}void delayus(uint t)//1T单片机微秒延时函数{ unsigned int a,b;for(b=t;b>0;b--)for(a=3;a>0;a--);}bit lcdbusy() //忙检查{bit result;RS=0;RW=1;E=1;delayus(5);result=(bit)(P0&0x80);E=0;return(result) ;}void writecmd(uchar cmd) //写命令{while(lcdbusy()) ;RS=0;RW=0;E=0;delayus(5);P0=cmd;delayus(10);E=1;delayus(5);E=0;}void writedat(uchar dat) //写数据{while(lcdbusy()) ;RS=1;RW=0;E=0;delayus(5);P0=dat;delayus(10);E=1;delayus(5);E=0;}void lcdpos(uchar x,uchar y)//液晶屏显示位置,x轴0~7,y轴0~7 {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;writecmd(pos);}void print(uchar *str) //液晶屏显示数组{while(*str!='\0'){writedat(*str);str++;}}void lcdclear()//液晶屏清屏函数{unsigned char i;writecmd(0x30);writecmd(0x80);writecmd(0x01);delayus(20);for(i=0;i<64;i++)writedat(' ');}void lcdinit()//液晶屏初始化{PSB=1;//并口方式writecmd(0x30);//基本指令操作delayms(5);writecmd(0x06);//写一个字符后地址指针自动加1 delayms(5); writecmd(0x0c);//开显示,关光标delayms(5);writecmd(0x01);//清屏指令delayms(5);}void main(){lcdinit();lcdpos(0,0);//起始位(行数,列数)print("战斗机");lcdpos(0,5);print("巡洋舰");lcdpos(2,2);print("航空母舰");while(1);}(3)#include#define uchar unsigned char#define uint unsigned int#define lcddata P0sbit RS=P2^0;sbit RW=P2^1;sbit E=P2^2;sbit PSB=P2^3;uchar code dis1[]="战斗机"; //液晶屏一行显示8个汉字,16个字节(i=0;i<16;i++)uchar code dis2[]="巡洋舰";uchar code dis3[]="航空母舰";void delayms(uint n)//1T单片机毫秒延时函数{unsigned int x;while(n--){x=627;while(x--);}}void delayus(uint t)//1T单片机微秒延时函数{unsigned int a,b;for(b=t;b>0;b--)for(a=3;a>0;a--);}bit lcdbusy() //忙检查{bit result;RW=1;E=1;delayus(5);result=(bit)(P0&0x80);E=0;return(result) ;}void writecmd(uchar cmd) //写命令{while(lcdbusy()) ;RS=0;RW=0;E=0;delayus(5);P0=cmd;delayus(10);E=1;delayus(5);E=0;}void writedat(uchar dat) //写数据{while(lcdbusy()) ;RS=1;RW=0;E=0;delayus(5);P0=dat;delayus(10);delayus(5);E=0;}void lcdpos(uchar x,uchar y)//液晶屏显示位置,x轴0~7,y轴0~7 {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;writecmd(pos);}void lcdclear()//液晶屏清屏函数{unsigned char i;writecmd(0x30);writecmd(0x80);writecmd(0x01);delayus(20);for(i=0;i<64;i++)writedat(' ');}void lcdinit()//液晶屏初始化{PSB=1;//并口方式writecmd(0x30);//基本指令操作delayms(5);writecmd(0x06);//写一个字符后地址指针自动加1delayms(5);writecmd(0x0c);//开显示,关光标delayms(5);writecmd(0x01);//清屏指令delayms(5);}void main(){uint i;lcdinit();lcdpos(0,0);//起始位(行数,列数)for(i=0;i<6;i++)//占用字节数(一个汉字占两个字节,一个字母、数字、符号占一个字节)writedat(dis1[i]);lcdpos(0,5);for(i=0;i<6;i++)writedat(dis2[i]);lcdpos(2,2);for(i=0;i<8;i++)writedat(dis3[i]);while(1);}(4)#include#define uchar unsigned char#define uint unsigned int#define lcddata P0sbit RS=P2^0;sbit RW=P2^1;sbit E=P2^2;sbit PSB=P2^3;uchar code dis1[]="战斗机"; //液晶屏一行显示8个汉字,16个字节(i=0;i<16;i++)uchar code dis2[]="巡洋舰";uchar code dis3[]="航空母舰";void delayms(uint n)//1T单片机毫秒延时函数{unsigned int x;while(n--){x=627;while(x--);}}void delayus(uint t)//1T单片机微秒延时函数{unsigned int a,b;for(b=t;b>0;b--)for(a=3;a>0;a--);}bit lcdbusy() //忙检查{bit result;RS=0;RW=1;E=1;delayus(5);result=(bit)(P0&0x80);E=0;return(result) ;}void writecmd(uchar cmd) //写命令{while(lcdbusy()) ;RS=0;RW=0;E=0;delayus(5);P0=cmd;delayus(10);E=1;delayus(5);E=0;}void writedat(uchar dat) //写数据{while(lcdbusy()) ;RS=1;RW=0;E=0;delayus(5);P0=dat;delayus(10);E=1;delayus(5);E=0;}void lcdpos(uchar x,uchar y)//液晶屏显示位置,x轴0~7,y轴0~7 {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;writecmd(pos);}void lcdclear()//液晶屏清屏函数{unsigned char i;writecmd(0x30);writecmd(0x80);writecmd(0x01);delayus(20);for(i=0;i<64;i++)writedat(' ');}void lcdinit()//液晶屏初始化{PSB=1;//并口方式writecmd(0x30);//基本指令操作delayms(5);writecmd(0x06);//写一个字符后地址指针自动加1 delayms(5); writecmd(0x0c);//开显示,关光标delayms(5);writecmd(0x01);//清屏指令delayms(5);}void main(){uint i;lcdinit();lcdpos(0,0);//起始位(行数,列数)i=0;while(dis1[i]!='\0'){writedat(dis1[i]);//显示字符i++;}lcdpos(0,5);i=0;while(dis2[i]!='\0'){writedat(dis2[i]);i++;}lcdpos(2,2);i=0;while(dis3[i]!='\0'){writedat(dis3[i]);i++;}while(1); }(5)#include#define uchar unsigned char#define uint unsigned intsbit CS=P2^0; //片选信号sbit SID=P2^1; //数据信号sbit SCLK=P2^2; //时钟信号sbit PSB=P2^3; //串并行选择,H并行,L串行sbit key=P3^0;unsigned char code temp1[]={"战斗机"}; unsigned char code temp2[]={"航空母舰"};void delayms(uint n)//毫秒延时{unsigned int x;while(n--){x=627;while(x--);}}void delay(uint m)//100us延时{unsigned int da,db;for(da=0;da<m;da++)< bdsfid="537" p=""></m;da++)<> for(db=0;db<100;db++);}void sendbyte(uchar bbyte) //发送一个字节{unsigned char i;for(i=0;i<8;i++){SID=bbyte&0x80;SCLK=1;SCLK=0;bbyte<<=1;}}void writechar(bit start,uchar ddata) //写指令或数据{unsigned char start_data,Hdata,Ldata;if(start==0)start_data=0xf8;elsestart_data=0xfa;Hdata=ddata&0xf0;Ldata=(ddata<<4)&0xf0;sendbyte(start_data);delay(5);sendbyte(Hdata);delay(1);sendbyte(Ldata);delay(1);}void lcdsetxy(uchar x,uchar y)//设置LCD显示的起始位置,X 为行,Y为列{uchar address;switch(x){case 0: address = 0x80 + y; break;case 1: address = 0x80 + y; break;case 2: address = 0x90 + y; break;case 3: address = 0x88 + y; break;case 4: address = 0x98 + y; break;default:address = 0x80 + y; break;}writechar(0, address);}void print(uchar X,uchar Y,uchar *s)//中英文字符串显示函数{lcdsetxy( X, Y );while (*s){writechar( 1, *s );s ++;delay(1);}}void lcdclear() //清屏函数{writechar(0,0x01);}void lcdinit(){delay(10);PSB=0;CS=1;writechar(0,0x30); writechar(0,0x0c); writechar(0,0x01); } void main(){lcdinit();print(1,2,temp1);print(3,2,temp2);while(1);}。

12864的液晶显示程序(无字库)

12864的液晶显示程序(无字库)

12864的液晶显示程序(无字库)12864.h#ifndef __12864_H__#define __12864_H__#include#include/***************************************利用I/O口模拟点阵液晶所需时序点阵液晶控制端口定义,需根据硬件适当改变****************************************/sbit LCD_RS = P2^0;//控制端口定义sbit LCD_RW = P2^1;sbit LCD_E = P2^2;sbit LCD_CSA = P2^3;//H选通,即高电平有效sbit LCD_CSB = P2^4;#define LCD_Data P0//LCD数据端口8位#define R 1#define L 2/*****************************************函数声明*****************************************/void ReadStatusLCD(unsigned char select);//从LCD读出忙标志位unsigned char ReadDataLCD(unsigned char select);//从LCD 读出数据void WriteDataLCD(unsigned char WDLCD,unsigned char select);//向LED写入数据void WriteCommandLCD(unsigned char WCLCD , unsigned char BusyC,unsigned char select);//向LCD写入命令void LcdReset(void) ;//初始化函数,完成液晶模块的初始设置void clear_LCD(unsigned char select);//清屏函数void Clr_All_Lcd(void);//全清屏函数void set_XY(unsigned char Column,unsigned char Page);//设置数据写入或读出的地址,通过页号和列数可以唯一确定一个地址void xy_Write(unsigned char Column,unsigned char Page,unsigned char dataW);//向指定行列写数据void LcmPutDots(unsigned char Column,unsigned char Page, unsigned char DotByte );//显示点void whiteword(unsigned char Column,unsigned char Page, const unsigned char puts[][16] );//显示16×16点阵的编码void WhiteWord_Com(unsigned char Column,unsigned char Page,unsigned char C_num,unsigned char V_num, unsigned char * puts );//通用的显示函数void Drawing_dot(unsigned char x,unsigned char y);void Drawing_line_vertical(unsigned x);#endif12864.c/****************************************************LCD12864点阵液晶屏,通过I/O口直接控制,采用模拟时序控制****************************************************/#include"12864.h"#include/*********************************************************** 功能:从LCD读取状态位变量:select用于选择LCD屏的左右,1选择左屏,2选择右屏***********************************************************/ void ReadStatusLCD(unsigned char select){switch(select){case 1:{LCD_CSA=1;LCD_CSB=0;break;}//左case 2:{LCD_CSA=0;LCD_CSB=1;break;}//右default: break;}LCD_Data = 0xff;//置位输入口,已实现输入LCD_RS=0;LCD_RW=1;LCD_E=1;//高电平读取数据//_nop_(); //若晶振速度高,可在此作延时处理while(LCD_Data&0x80);//最高位为忙标志,检测忙信号状态LCD_E=0;//_nop_(); //若晶振速度高,可在此作延时处理}/*********************************************************** 功能:从LCD读取数据变量:select用于选择LCD屏的左右,1选择左屏,2选择右屏***********************************************************/ unsigned char ReadDataLCD(unsigned char select){unsigned char dataR;LCD_Data = 0xff;//置位输入口,已实现输入switch(select){case 1:{LCD_CSA=1;LCD_CSB=0;break;}//左case 2:{LCD_CSA=0;LCD_CSB=1;break;}//右default: break;}LCD_RW=1;LCD_RS=1;LCD_E = 1;// 操作允许脉冲信号,高电平读出//_nop_(); //若晶振速度高,可在此作延时处理dataR = LCD_Data;LCD_E= 0;return dataR;}/***********************************************************功能:向LCD写入数据参数:WDLCD待写入的字符数据select用于选择LCD屏的左右,1选择左屏,2选择右屏***********************************************************/void WriteDataLCD(unsigned char WDLCD,unsigned char select){switch(select){case 1:{LCD_CSA=1;LCD_CSB=0;break;}//左case 2:{LCD_CSA=0;LCD_CSB=1;break;}//右default: break;}ReadStatusLCD(select);//检测忙标志LCD_RS = 1;LCD_RW = 0;LCD_Data = WDLCD;LCD_E = 1;//_nop_(); //若晶振速度高,可在此作延时处理LCD_E = 0; //下降沿写入数据//_nop_(); //若晶振速度高,可在此作延时处理}/***********************************************************功能:向LCD写入命令参数:WDLCD待写入的字符数据BusyC是否要检查忙标志位选择标志,1为进行,0为不检测select用于选择LCD屏的左右,1选择左屏,2选择右屏***********************************************************/void WriteCommandLCD(unsigned char WCLCD , unsigned char BusyC,unsigned char select) {if(BusyC) ReadStatusLCD(select);//根据需要检测忙switch(select){case 1:{LCD_CSA=1;LCD_CSB=0;break;}//左case 2:{LCD_CSA=0;LCD_CSB=1;break;}//右default: break;}LCD_Data = WCLCD;LCD_RS = 0;LCD_RW = 0;LCD_E = 1;//_nop_(); //若晶振速度高,可在此作延时处理LCD_E = 0;}/************************************************************** **************** 功能:清显示RAM区(清屏)参数:select为驱动控制器选择1为左2为右*************************************************************** **************** */void clear_LCD(unsigned char select){unsigned char i,j;for(i=0;i<8;i++){ //8页,换页清零WriteCommandLCD( 0xb8|i,1 ,select);//页面地址设置,并分别写入左右模块中WriteCommandLCD( 0x40,1 ,select);//列地址设置,设置为0列,并分别写入左右三个模块中for(j=0;j<64;j++){ //页内清零WriteDataLCD( 0 ,select);}}}/************************************************************** *************** 功能:清LCD左右屏*************************************************************** **************/ void Clr_All_Lcd(void){clear_LCD(1);clear_LCD(2);}/************************************************************** **************** 功能:LCD初始化,分为左,右模块初始化参数:select为驱动控制器选择1为左2为右*************************************************************** **************** */void LcdReset(void){unsigned char i;for(i=0;i<5;i++){WriteCommandLCD( 0xc0,0 ,R);//设置显示起始行为第一行,并分别写入左右模块中,不检测忙标志WriteCommandLCD( 0xc0,0 ,L);//_nop_(); //若晶振速度高,可在此作延时处理}WriteCommandLCD( 0xc0,1 ,R);//设置显示起始行为第一行,并分别写入左右模块中,检测忙标志WriteCommandLCD( 0xc0,1 ,L);WriteCommandLCD( 0x3f,1 ,R);//开显示设置,并分别写入左右模块中WriteCommandLCD( 0x3f,1 ,L);clear_LCD(R);//清左屏clear_LCD(L);//清右屏}/************************************************************** **************** 功能:设置数据写入或读出的地址,通过页号和列数可以唯一确定一个地址参数:Column表示列号,Page表示页号*************************************************************** **************** */void set_XY(unsigned char Column,unsigned char Page){unsigned char x,y;unsigned char select;switch (Column&0x40) //完成左右屏的判断,根据列号完成区分,<64为左屏,>=64为右屏{case 0x00: {select = 1;ReadStatusLCD(select);break;}/*为左区*/case 0x40: {select = 2;ReadStatusLCD(select);break;}/*为右区*/}x = Column&0x3F|0x40; /* col.and.0x3f.or.Set Y Address*/ y = Page&0x07|0xB8; /* row.and.0x07.or.set Page */WriteCommandLCD( y,1 ,select);//设置页面地址WriteCommandLCD( x,1 ,select);//设置列地址}/************************************************************** **************** 功能:根据地址值(页数和列号),写入数据,即写入显示缓冲区,便可以显示在LCD屏上参数:Column表示列号,Page表示页号,dataW表示待写入的数据*************************************************************** **************** */void xy_Write(unsigned char Column,unsigned char Page,unsigned char dataW){set_XY(Column,Page);LCD_RW=0;LCD_RS=1;_nop_();//若晶振速度高,可在此作延时处理LCD_Data = dataW;// 送数据_nop_(); //若晶振速度高,可在此作延时处理LCD_E = 1;_nop_(); //若晶振速度高,可在此作延时处理LCD_E= 0; // 操作允许脉冲信号,下降沿写入}/************************************************************** **************** 功能:用于显示点阵参数:Column表示列号,Page表示页号,*************************************************************** **************** */void LcmPutDots(unsigned char Column,unsigned char Page, unsigned char DotByte ){unsigned char i;i=Column;for(;Page<8;Page++){for(;Column<128;Column++){xy_Write(Column,Page,DotByte);//DotByte = ~DotByte;}Column=i;}}/************************************************************** **************** 功能:在指定列,指定页显示待显示的点阵编码,用于显示16*16点阵码参数:Column表示列号,Page表示页号,puts待显示的点阵编码首指针*************************************************************** **************** */void whiteword(unsigned char Column,unsigned char Page, const unsigned char puts[][16] ){unsigned char i,j;for(i=0;i<2;i++)//此处的2为控制点阵行数,实际点阵行数为2*8=16行,此处的16(对应的点行数)应为8的倍数{for(j=0;j<16;j++)//此处控制每行显示的列数{xy_Write(Column+j,Page+i,puts[i][j]);}}}/****************************************************************************** 功能:在指定列,指定页显示待显示指定点阵的编码参数:Column表示列号,Page表示页号,C_num为显示点阵的行数(物理行8的倍数),V_num 为列(物理列)puts待显示的点阵编码首指针*************************************************************** **************** */void WhiteWord_Com(unsigned char Column,unsigned char Page,unsigned char C_num,unsigned char V_num, unsigned char * puts){unsigned char i,j;for(i=0;i<(C_num/8);i++)//此处的2为控制点阵行数,实际点阵行数为2*8=16行,此处的16(对应的点行数)应为8的倍数{for(j=0;j<="">{xy_Write(Column+j,Page+i,*(puts+i*V_num+j));//注意地址的变化规律}}}/************************************************************** **************** 功能:绘点参数:Column表示列号,Page表示页号,C_num为显示点阵的行数(物理行8的倍数),V_num 为列(物理列)puts待显示的点阵编码首指针*************************************************************** **************** */void Drawing_dot(unsigned char x,unsigned char y){unsigned char y_byte,x_bit,y_bit,reverse_y;//此处y_byte为page,y_bit为具体行号,x_bit 为行号unsigned char dot;reverse_y=63-y;x_bit=x;y_byte=reverse_y/8;y_bit=y%8;// for(;x_bit<128;x_bit++)if(y_bit==0) dot=0x80;if(y_bit==1) dot=0x40;if(y_bit==2) dot=0x20;if(y_bit==3) dot=0x10;if(y_bit==4) dot=0x08;if(y_bit==5) dot=0x04;if(y_bit==6) dot=0x02;if(y_bit==7) dot=0x01;xy_Write(x_bit,y_byte,dot);/* reverse_y=64-y;if(y_bit==7) y_byte=y_byte-1;y_bit=y%8;if(y_byte==(-1)) break;*/}/************************************************************** **************** 功能:绘垂直直线参数:x表示列号*************************************************************** **************** */void Drawing_line_vertical(unsigned char x){xy_Write(x,0,0xff);xy_Write(x,1,0xff);xy_Write(x,2,0xff);xy_Write(x,3,0xff);xy_Write(x,4,0xff);xy_Write(x,5,0xff);xy_Write(x,6,0xff);xy_Write(x,7,0xff);}主程序.c/************************************************************** **************** ****************12864液晶屏上显示"南京绝妙科技发展有限公司,025-******** 开发板欢迎使用","0~9",刷新后重显。

12864 LCD驱动程序

12864 LCD驱动程序

/*LCD.C128×64 LCD驱动程序*/#include <INTRINS.H>#include <ABSACC.H>#include "LCD.H"//定义屏幕光标(取值0~63,光标本身不可见)unsigned char LcdCursor;/*函数:LcdLightOn()功能:点亮背光灯*/void LcdLightOn(){LCD_BL = 1;}/*函数:LcdLightOff()功能:熄灭背光灯*/void LcdLightOff(){LCD_BL = 0;}/*函数:LcdGetBF()功能:读出状态位BF返回:BF=1,表示忙,不可进行任何操作BF=0,表示不忙,可以进行正常操作*/bit LcdGetBF(){unsigned char dat;dat = XBYTE[0xD002]; //XBYTE的定义见<ABSACC.H>return (bit)(dat & 0x80);}/*函数:LcdWriteCmd()功能:向LCD发送命令参数:cmd:命令字,详见器件的数据手册*/void LcdWriteCmd(unsigned char cmd){while ( LcdGetBF() );XBYTE[0xD000] = cmd;}/*函数:LcdWriteDat()功能:向LCD写入数据参数:dat,要写入的数据说明:目标地址由地址计数器AC隐含指定,写完后AC自动加1*/void LcdWriteDat(unsigned char dat){while ( LcdGetBF() );XBYTE[0xD001] = dat;}/*函数:LcdReadDat()功能:从LCD读出数据返回:读出的数据*//*unsigned char LcdReadDat(){volatile unsigned char dat;while ( LcdGetBF() );dat = XBYTE[0xD003];dat = XBYTE[0xD003]; //需要连续执行两次才能够读出真正的数据return dat;}*//*函数:LcdSetAC()功能:设置DDRAM(显示数据RAM)的AC(地址计数器)值参数:ac:地址计数器值,范围0~63*/void LcdSetAC(unsigned char ac){ac &= 0x3F;ac |= 0x80;LcdWriteCmd(ac);}/*函数:LcdClear()功能:LCD清屏,并使光标回到0*/void LcdClear(){LcdWriteCmd(0x01); //清屏命令LcdCursor = 0;}/*函数:LcdDelay()功能:延时(t*100)个机器周期*/void LcdDelay(unsigned char t){unsigned char n;do{n = 49;while ( --n != 0 );} while ( --t != 0 );}/*函数:LcdInit()功能:LCD初始化*/void LcdInit(){LcdWriteCmd(0x30); //设置基本指令集LcdDelay(3);LcdWriteCmd(0x30); //设置基本指令集(需要再执行一次)LcdDelay(1);LcdWriteCmd(0x0C); //开启显示LcdDelay(3);LcdClear(); //清屏LcdDelay(250);LcdWriteCmd(0x06); //设置进入点LcdDelay(10);}/*函数:LcdCheckAC()功能:根据光标位置调整AC*/void LcdCheckAC(){switch ( LcdCursor ){case 16:LcdSetAC(16);break;case 32:LcdSetAC(8);break;case 48:LcdSetAC(24);break;case 64:LcdCursor = 0;LcdSetAC(0);break;default:break;}/*函数:LcdPutChar()功能:显示ASCII码参数:c为可显示的ASCII码(0x20~0x7F)*/void LcdPutChar(unsigned char c){LcdWriteDat(c);LcdCursor++;LcdCheckAC();}/*函数:LcdPutHZ()功能:显示汉字参数:ch,cl:汉字编码*/void LcdPutHZ(unsigned char ch, unsigned char cl){if ( LcdCursor & 0x01 ){//显示汉字时,必须偶地址对准,即光标位置不能是奇数LcdPutChar(' '); //额外输出一个空格}LcdWriteDat(ch);LcdWriteDat(cl);LcdCursor += 2;LcdCheckAC();}/*函数:LcdPuts()功能:显示字符串参数:*s:要显示的字符串(可同时包含ASCII码和汉字)*/void LcdPuts(unsigned char *s){unsigned char ch, cl;for (;;){ch = *s++;if ( ch == '\0' ) break;if ( ch < 0x80 ){LcdPutChar(ch);}else{cl = *s++;LcdPutHZ(ch,cl);}}}。

12864液晶显示C程序

12864液晶显示C程序

#include <reg51.h>#include <intrins.h>//_nop_();延时函数用#define unchar unsigned char#define unint unsigned intsbit E=P3^0;sbit RW=P3^1;sbit RS=P3^2;sbit CS1=P3^6;sbit CS2=P3^7;char code tablenum[][16]={0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00, // 0 0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, //1 0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00, //2 0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00, //3 0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00, //4 0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00, //5 0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00, //6 0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00, //7 0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00, //8 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00, //9 0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00, //: 0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20, //R 0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00, //S 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00, //.};char code tablesnum[][4]={0x00,0x7c,0x44,0x7c,//小00x00,0x00,0x7c,0x00,//小10x00,0x74,0x54,0x5c,//小20x00,0x54,0x54,0x7c,//小30x00,0x3c,0x20,0x7c,//小40x00,0x5c,0x54,0x74,//小50x00,0x7c,0x54,0x74,//小60x00,0x04,0x04,0x7c,//小70x00,0x7c,0x54,0x7c,//小80x00,0x5c,0x54,0x7c,//小90x08,0x08,0x08,0x08,};//void delay(unint i)//{//while(--i);//}void readbusy()//是否忙碌{P0=0x00;RS=0;RW=1;E=1;while(P0&0x80);E=0;}void writecommand(unchar command) //写命令{readbusy();RS=0;RW=0;P0=command;E=1;_nop_();_nop_();E=0;}void writedate(unchar date) //写数据{readbusy();RS=1;RW=0;P0=date;E=1;_nop_();_nop_();E=0;}void setpage(unchar page)//设置页{page=0xb8|page;writecommand(page);}void setline(unchar line)//设置行{line=0xc0|line;writecommand(line);}void setcolumn(unchar column)//设置列{column=column&0x3f;column=0x40|column; writecommand(column);}void setonoff(unchar onoff){onoff=0x3e|onoff;writecommand(onoff);}void selectscreen(unchar screen)//选屏{switch(screen){case 0:CS1=0;CS2=0;break;case 1:CS1=0;CS2=1;break;case 2:CS1=1;CS2=0;break; default: break;}}void clearscreen(unchar screen)//清屏{unchar i,j;selectscreen(screen);for(i=0;i<8;i++){setpage(i);setcolumn(0);for(j=0;j<64;j++){writedate(0x00);}}}void InitLCD()//初始化readbusy();selectscreen(0);setonoff(0);selectscreen(0);setonoff(1);selectscreen(0);clearscreen(0);setline(0);}void display(unchar ss,unchar page,unchar column,unchar j)//显示数据{unchar i;selectscreen(ss);setpage(page);setcolumn(column);for(i=0;i<8;i++){writedate(tablenum[j][i]);}setpage(page+1);setcolumn(column);for(i=0;i<8;i++){writedate(tablenum[j][i+8]);}}void displays(unchar ss,unchar page,unchar column,unchar j)//显示小数据{unchar i;selectscreen(ss);setpage(page);setcolumn(column);for(i=0;i<4;i++){writedate(tablesnum[j][i]);}}void disnum()//显示数据{display(1,0,1*8,11);display(1,0,2*8,10);display(1,0,3*8,1);display(1,0,4*8,1);display(1,0,5*8,13);display(1,0,6*8,1);display(2,0,1*8,12);display(2,0,2*8,10);display(2,0,3*8,1);display(2,0,4*8,1);display(2,0,5*8,13);display(2,0,6*8,1);}void dissnum()//显示坐标数据{//displays(1,2,0*4,9);//displays(1,2,1*4,0); displays(1,3,0*4,7); displays(1,3,1*4,5);//displays(1,4,0*4,6);//displays(1,4,1*4,0); displays(1,5,0*4,4); displays(1,5,1*4,5);//displays(1,6,0*4,3);//displays(1,6,1*4,0); displays(1,7,0*4,1); displays(1,7,1*4,5);}void diszhou()//坐标轴{unchar i,j,a,b; selectscreen(1);for(i=2;i<7;i++){setcolumn(11);setpage(i);writedate(0xff);}setcolumn(11);setpage(7);writedate(0x0f);for(j=3;j<16;j++){displays(1,7,j*4,10); }for(b=2;b<7;b++){setcolumn(12);setpage(b);writedate(0x08);}setcolumn(12);setpage(7);writedate(0x08); for(a=0;a<16;a++) {displays(2,7,a*4,10); }}void main(){InitLCD(); clearscreen(0); writecommand(0xc0); disnum();dissnum();diszhou();while(1); }。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

{'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},
};
struct hanzifu
//
{
uchar hanzi[2];
uchar tabhanzi[32];
};
bit JiSuanLCD(uchar x,y,mode,uchar *p);
//计算显示汉字/字符程序
void FuWeiLCD(void);
//复位液晶
void JiSuanLCDShu(uchar x,y,mode,long int shu);
{'n',0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20}, {'o',0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00}, */ {'p',0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00}, /* {'q',0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80}, {'r',0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00}, {'s',0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00},*/ {'t',0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00}, /* {'u',0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20}, {'v',0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00}, {'w',0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00}, {'x',0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00}, {'y',0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00}, {'z',0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00}, {'A',0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20}, {'B',0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00}, {'C',0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00}, {'D',0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00}, {'E',0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00}, {'F',0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00}, {'G',0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00}, {'H',0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20}, {'I',0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00}, {'J',0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00}, {'K',0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00}, {'L',0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00}, {'M',0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00}, {'N',0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00}, {'O',0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00}, {'P',0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00}, {'Q',0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00}, {'R',0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20}, {'S',0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00}, {'T',0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00}, {'U',0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00}, {'V',0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00}, {'W',0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00}, {'X',0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20}, {'Y',0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00}, {'Z',0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00}, {' ',0x00,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,0x01,0x01,0x01,0x01,0x01,0x01}, */ {'.',0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00}, {'=',0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00}, };
相关文档
最新文档