DSP28335 扩展板12864显示汉字

合集下载

12864文字加图像显示

12864文字加图像显示

/***************************************************************************标题:LCD12864程序效果:本程序在LCD12864液晶屏显示汉字、字符及图形内容工作于:L Y5A-L2A开发板******************************************************************************/ #include "reg51.h"/********IO引脚定义***********************************************************/ sbit LCD_RS=P1^0;sbit LCD_RW=P1^1;sbit LCD_E=P1^2;sbit PSB =P1^6; //PSB脚为12864-12系列的串、并通讯功能切换,我们使用8位并行接口,PSB=1/********宏定义***********************************************************/#define LCD_Data P0#define Busy 0x80 //用于检测LCD状态字中的Busy标识/********函数声明*************************************************************/ void WriteDataLCD(unsigned char WDLCD); //写数据void WriteCommandLCD(unsigned char WCLCD,BuysC); //写指令unsigned char ReadDataLCD(void); //读数据unsigned char ReadStatusLCD(void); //读状态void LCDInit(void); //初始化void LCDClear(void); //清屏void LCDFlash(void); //闪烁效果void DisplayOneChar(unsigned char X, unsigned char Y, unsigned char DData); //按指定位置显示一个字符void DisplayListChar(unsigned char X, unsigned char Y, unsigned char code *DData); //按指定位置显示一串字符void Delay5Ms(void); //短延时void Delay400Ms(void); //长延时/********数据定义*************************************************************/ code unsigned char uctech[] = {"5 1 单片机实验板"};code unsigned char net[] = {" "};code unsigned char mcu[] = {"单片机因你而精彩"};code unsigned char qq[] = {" QQ: 12345678 "};code unsigned char tmp[]={//128*64点阵图形数据0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x8F,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x01,0xEF,0xFF,0x80,0x02,0x08,0x00,0x88,0x02,0x00,0x00,0x00,0x00,0x00,0x01, 0x80,0x00,0xFF,0xFF,0x80,0x02,0x08,0x0C,0xC8,0x02,0x00,0x7F,0xE1,0xEF,0xC0,0x01, 0x80,0x00,0xFF,0xFF,0x80,0x02,0x08,0x04,0x08,0x3F,0xE0,0x01,0x81,0x29,0x40,0x01, 0x80,0x00,0xFF,0xFC,0x40,0x0F,0xFF,0x01,0xFE,0x22,0x20,0x03,0x01,0x29,0x40,0x01, 0x80,0x01,0xFF,0xFC,0x20,0x02,0x18,0x10,0x20,0x22,0x20,0x06,0x01,0x29,0x40,0x01, 0x80,0x01,0xFF,0xFC,0x00,0x06,0x18,0x18,0x20,0x3F,0xE0,0x06,0x01,0x29,0x40,0x01, 0x80,0x01,0xFF,0xF8,0x10,0x07,0x2C,0x01,0xFC,0x22,0x20,0xFF,0xF1,0x2F,0xC0,0x01, 0x80,0x01,0xFF,0xFC,0x30,0x0E,0xAE,0x00,0x20,0x22,0x20,0x06,0x01,0x28,0x40,0x01, 0x80,0x03,0xFF,0xFC,0x38,0x0A,0x6A,0x00,0x20,0x22,0x20,0x06,0x01,0xE8,0x00,0x01, 0x80,0x03,0xFF,0xFE,0x18,0x0A,0x49,0x0F,0xFE,0x3F,0xE0,0x06,0x01,0x28,0x00,0x01, 0x80,0x03,0xFF,0xFE,0x18,0x02,0x08,0x08,0x20,0x22,0x00,0x06,0x01,0x08,0x20,0x01, 0x80,0x07,0xFF,0xFF,0x17,0x02,0x08,0x18,0x20,0x02,0x08,0x06,0x00,0x08,0x20,0x01, 0x80,0x07,0xFF,0xBF,0x8F,0x82,0x08,0x10,0x20,0x03,0xF8,0x0C,0x00,0x07,0xE0,0x01, 0x80,0x0F,0xFE,0x03,0xF7,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 0x80,0x0F,0xFC,0x00,0x8A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 0x80,0x0F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 0x80,0x07,0xF8,0x00,0x08,0x00,0x00,0x00,0x0C,0x01,0x80,0xE0,0x00,0x00,0x00,0x01, 0x80,0x01,0xF8,0x00,0x20,0x00,0x00,0x00,0x04,0x00,0x81,0x20,0x00,0x00,0x00,0x01, 0x80,0x00,0xF8,0x00,0x20,0x00,0x00,0x00,0x04,0x00,0x81,0x20,0x00,0x00,0x00,0x01, 0x80,0x01,0xF8,0x04,0x80,0x01,0xFF,0xFC,0x04,0xFB,0xBC,0xC0,0x39,0x9F,0x00,0x01, 0x80,0x00,0x5C,0x01,0x00,0x01,0x6B,0x58,0x04,0x54,0x89,0x20,0x42,0x55,0x00,0x01, 0x80,0x00,0x0E,0x05,0x00,0x00,0xA5,0x28,0x04,0x24,0x91,0x20,0x42,0x55,0x00,0x01, 0x80,0x00,0x07,0xE8,0x00,0x00,0xA5,0x29,0x0E,0x43,0xFC,0xC4,0x39,0x95,0x00,0x01, 0x80,0x00,0x0F,0xE0,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x01, 0x80,0x00,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 0x80,0x00,0x3F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 0x80,0x00,0xFE,0xE8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x01, 0x80,0x00,0xFB,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xC0,0x00,0x01, 0x80,0x00,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xE0,0x00,0x01, 0x80,0x00,0xF7,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x01, 0x80,0x00,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x01, 0x80,0x01,0xF7,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x01, 0x80,0x00,0xFF,0xCC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0xE0,0x00,0x01, 0x80,0x01,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x60,0x00,0x01, 0x80,0x01,0xFF,0x6E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x20,0x38,0x01, 0x80,0x01,0xF7,0xB7,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x30,0xFE,0x01, 0x80,0x03,0xFB,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x21,0xFF,0x01, 0x80,0x01,0xFD,0xFF,0xC0,0x00,0x40,0x00,0x00,0x13,0x00,0x00,0x03,0x61,0xFF,0x81, 0x80,0x03,0xFF,0xFA,0xE0,0x00,0x40,0x27,0xF8,0x22,0x00,0x00,0x01,0x83,0xFF,0x81, 0x80,0x07,0xFF,0x7F,0xC0,0x3E,0xFE,0x36,0x48,0x67,0xF0,0x20,0x01,0xC1,0xFF,0x81, 0x80,0x07,0xFB,0xDC,0xC0,0x02,0x86,0x06,0x48,0x6C,0x90,0x20,0x01,0x63,0xFF,0x81, 0x80,0x03,0x7E,0xFF,0xC0,0x12,0x84,0x06,0x48,0xA0,0x80,0x20,0x03,0x3B,0xFF,0x81, 0x80,0x0F,0xDF,0xFE,0x00,0x15,0xA0,0x76,0x48,0x24,0xB0,0x20,0x0E,0x1F,0xFF,0x81,0x80,0x03,0xFF,0xBE,0x00,0x0C,0x20,0x16,0x48,0x21,0x80,0x20,0x3F,0x07,0xFF,0x87,0x80,0x0F,0xBF,0xBE,0x00,0x0E,0x30,0x17,0x58,0x02,0x00,0x20,0x3F,0x1F,0xFF,0xC7,0x80,0x3F,0xDF,0xFE,0x00,0x1A,0x70,0x16,0x50,0x2B,0x20,0x20,0x7E,0x1F,0xFF,0xC7,0x81,0xFF,0xFF,0xBF,0x80,0x12,0x48,0x10,0x40,0x49,0x10,0x30,0x1E,0x1F,0xFF,0xC7,0x9F,0xFF,0x3F,0xFF,0xE0,0x30,0x84,0x38,0x00,0x48,0x58,0x00,0x1C,0x1F,0xFF,0xFD,0xDF,0xFF,0x7F,0xBF,0xF0,0x03,0x02,0x47,0xFC,0x4F,0xC0,0x00,0x3C,0x0F,0xFF,0xF5,0xFF,0xFC,0xFF,0xF7,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x0F,0xFF,0x81,0xFF,0xF8,0x7F,0xFB,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x07,0xFE,0x01,0xBF,0xE8,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x03,0xF8,0x01,0x9F,0xA0,0xFF,0xFB,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x01,0x60,0x01,0x80,0x81,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0xFF,0xFD,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};/***********主函数开始********************************************************/ void main(void){Delay400Ms(); //启动等待,等LCD讲入工作状态LCDInit(); //LCD初始化Delay5Ms(); //延时片刻(可不要)while(1){LCDClear();DisplayImage(tmp); //显示图形Delay400Ms();Delay400Ms();Delay400Ms();Delay400Ms();Delay400Ms();Delay400Ms();Delay400Ms();Delay400Ms();LCDClear();DisplayListChar(0,1,uctech); //显示字库中的中文数字DisplayListChar(0,2,net); //显示字库中的中文数字DisplayListChar(0,3,mcu); //显示字库中的中文DisplayListChar(0,4,qq); //显示字库中的中文数字Delay400Ms();Delay400Ms();Delay400Ms();Delay400Ms();LCDFlash(); //闪烁效果}。

12864中文字库液晶模块使用说明书

12864中文字库液晶模块使用说明书

12864中文字库液晶模块使用说明书第 1 页共16 页一、12864液晶显示模块概述1. 12864液晶显示模块是128×64点阵的汉字图形型液晶显示模块,可显示汉字及图形,内置国标GB2312码简体中文字库(16X16点阵)、128个字符(8X16点阵)及64X256点阵显示RAM(GDRAM)。

可与CPU 直接接口,提供两种界面来连接微处理机:8-位并行及串行两种连接方式。

具有多种功能:光标显示、画面移位、睡眠模式等。

2. 外观尺寸:93×70mm(4X8C), 84×44mm(2X8C),110×65mm(2x8 C _2), 116×39mm(2X10),180×65mm(4X16A)3. 视域尺寸:73×39mm(4X8C), 78×25mm(2x8 C _2), 70×20mm(2X8C),85×20mm(2X10), 132×39mm(4X16A),补充说明:外观尺寸可根据用户的要求进行适度调整。

二、模块引脚说明1)表—1:(128X32)、(160X32)模块引脚说明引脚名称 方向 说明 引脚名称方向 说明1 VSS - GND(0V) 11 DB4 I/O 数据42 VDD - Supply Voltage For Logic (+5v) 12 DB5 I/O 数据53 VO - Supply Voltage For LCD (悬空)13 DB6 I/O 数据64 RS(CS) H/L H: Data L: Instruction Code 14 DB7 I/O 数据75 R/W(STD) H/L H: Read L: Write15 PSB H/L 16032此脚为:RESET脚 6 E(SCLK) H,H/L Enable Signal7 DB0 I/O 数据0 16 /RST H/L 16032此脚为空8 DB1 I/O 数据1 17 LEDK - 16032此脚为A9 DB2 I/O 数据2 18 LEDA - 16032此脚为K10 DB3 I/O 数据3 注:以上K为负,A为正4)表—4:(256X64)引脚说明引脚名称 方向 说明引脚名称 方向 说明 1 FG - FRAME GROUND 11 DB0 I/O 数据0 2 VSS - GND(0V)12 DB1 I/O 数据1 3 VDD - Supply Voltage For Logic (+5v) 13 DB2 I/O 数据2 4 NC - 空脚14 DB3 I/O 数据3 5 R/W H/L H: Read L: Write 15 DB4 I/O 数据4 6 E1 H,H/L Enable Signal1 16 DB5 I/O 数据5 7 E2 H,H/L Enable Signal217 DB6 I/O 数据6 8 RS H/L H: Data L: Instruction Code 18 DB7 I/O 数据7 9 NC - 空脚19 NC - 空脚 10 /RST H/L Reset Signal 低电平有效 20 NC - 空脚注 K背光源负极(LED-OV)A背光源正极(LED+5V)三、12864液晶硬件接口1、逻辑工作电压(VDD):4.5~5.5V2、电源地(GND):0V3、LCD 驱动电压(V0):0~-10V4、工作温度(Ta):0~55℃(常温) / -20~70℃(宽温) 保存温度(Tstg):-10~65℃(常温)5、电气特性见附图1 外部连接图(参考附图2)模块有并行和串行两种连接方法(时序如下): 1、8位并行连接时序图MPU 写资料到模块RSR/WEMPU从模块读出资料RSR/WE2、串行连接时序图CS C LS T3、AC电气特性(TA=25℃ VCC=5V)condition Min. Typ. Max. UnitSYMBOL Characteristics Testfrequency Rf=39KΩ480 540 600 KHz Fosc OSCTIME UNIT PARAMETER SYMBOL MESUREFOR WRITE MODE(WRITING DATA FROM MPU TO ST7920)System cycle time TC 13,000 nsAddress setup time TAS 1,500 nsAddress hold time TAH 1,500 nsData setup time TDSW 1,000 nsData hold time TH 20 nsEnable pulsewidth TPW 1,500 nsEnable rise/fall time TR,TF 25 nsFOR READ MODE(READING DATA FROM ST7920 TO MPU)System cycle time TC 13,000 nsAddress setup time TAS 1,500 nsAddress hold time TAH 1,500 nsData setup time TDDR 1,000 nsData hold time TH 20 ns Enable pulsewidth TPW 1,500 ns Enable rise/fall time TR,TF 25 ns四、用户指令集指令表—2:(RE=1:扩充指令集)指令码指令RS RW DB7 DB6 DB5DB4 DB3 DB2DB1DB0说明执行时间(540KHZ )待命模式 0 0 0 0 0 0 0 0 0 1将DDRAM 填满“20H ”,并且设定DDRAM 的地址计数器(AC )到“00H ” 72us卷动地址或IRAM 地址选择 0 0 0 0 0 0 0 0 1 SR SR=1:允许输入垂直卷动地址 SR=0:允许输入IRAM 地址72us反白选择 0 0 0 0 0 0 0 1 R1 R0选择4行中的任一行作反白显示,并可决定反白与否 72us 睡眠模式0 0 0 0 0 0 1 SL X XSL=1:脱离睡眠模式 SL=0:进入睡眠模式72us扩充功能设定0 0 0 0 1 1 X1REG 0RE=1:扩充指令集动作RE=0:基本指令集动作G=1 :绘图显示ONG=0 :绘图显示OFF72us设定IRAM地址或卷动地址0 0 0 1 AC5AC4 AC3 AC2AC1AC0SR=1:AC5—AC0为垂直卷动地址SR=0:AC3—AC0为ICON IRAM地址72us设定绘图RAM地址0 0 1 AC6 AC5AC4 AC3 AC2AC1AC0设定CGRAM地址到地址计数器(AC)72us备注:1、当模块在接受指令前,微处理顺必须先确认模块内部处于非忙碌状态,即读取BF标志时BF需为0,方可接受新的指令;如果在送出一个指令前并不检查BF标志,那么在前一个指令和这个指令中间必须延迟一段较长的时间,即是等待前一个指令确实执行完成,指令执行的时间请参考指令表中的个别指令说明。

12864显示汉字

12864显示汉字

#include<reg52.h>#include<intrins.h>//声明_nop_();#define uchar unsigned char#define uint unsigned int//sbit ce=P2^3;//#define LCD_databus P0sbit rs=P2^2;sbit en=P2^0;sbit rw=P2^1;sbit cs1=P2^4;sbit cs2=P2^3;uchar num;/*void delay(uint z){uint x,y;for(x=z;x>0;x--)for(y=110;y>0;y--);}*/void write_LCD_command(uchar value)//指令函数{rs=0;//RS=1为数据操作,RS=0为写指令或读状态rw=0;// LCD_databus=value;P0=value;en=1;_nop_();//延时一个机器周期12M晶振的话就是1us 只是为了更精确的延时_nop_();en=0;}void write_LCD_data(uchar value)//数据函数{rs=1;//RS=1为数据操作,RS=0为写指令或读状态rw=0;// LCD_databus=value;P0=value;en=1;_nop_();_nop_();//延时一个机器周期12M晶振的话就是1us 只是为了更精确的延时en=0;}void Set_page(uchar page)//设置页,12864LCD共有8页,每页有8行点阵点。

{page=0xb8|page;//首页地址为0XB8write_LCD_command(page);}void Set_line(uchar startline)//设置显示的起始行,共有0--63行,一般从0行开始显示{startline=0xc0|startline;//起始行地址0XC0write_LCD_command(startline);}void Set_column(uchar column)//设置显示的列{column=column&0x3f; //列的最大值为0X3F,即64column=0x40|column; //列的首地址为0X40,write_LCD_command(column);}void Set0n0ff(uchar onoff)//设置显示开关,onoff取值为0或{onoff=0x3e|onoff;//0X3E是关显示,0X3F是开显示write_LCD_command(onoff);//所以若onoff为0,则表示关显示,onoff为1,则表示开显示}void SelectScreen(uchar 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(uchar screen)//青萍{uchar i,j;SelectScreen(screen);for(i=0;i<8;i++){Set_page(i);Set_column(0);for(j=0;j<64;j++){write_LCD_data(0x00);}}}void InitLCD()//初始化{SelectScreen(0);Set0n0ff(0);SelectScreen(0);Set0n0ff(1);SelectScreen(0);ClearScreen(0);Set_line(0);}void show(uchar screen,uchar page,uchar column,uchar *p)//screen表示选择屏幕,page表示页,column表示列,*p表示汉字的数组{uchar i;SelectScreen(screen); //选屏Set_page(page); //设置页,写上半页Set_column(column);//设置列for(i=0;i<16;i++) //控制16列的数据输出{write_LCD_data(p[i]);} //汉字的上半部分Set_page(page+1); //写下半页Set_column(column); //控制列for(i=0;i<16;i++) //控制16列的数据输出{write_LCD_data(p[i+16]);} //汉字的下半部分}/*void Display(uchar ss,uchar page,uchar column,uchar *p){uchar i;SelectScreen(ss);Set_page(page);Set_column(column);for(i=0;i<16;i++){write_LCD_data(p[i]);}}*unsigned char code huan[]= // 欢{0x04,0x24,0x44,0x84,0x64,0x9C,0x40,0x30,0x0F,0xC8,0x08,0x08,0x28,0x18,0x00,0x00,0x10,0x08,0x06,0x01,0x82,0x4C,0x20,0x18,0x06,0x01,0x06,0x18,0x20,0x40,0x80,0x00};*/unsigned char code pu[]={0x04,0x04,0x24,0x24,0x64,0xAF,0x24,0x34,0x24,0xAF,0x64,0x34,0x24,0x86,0x04,0x00, 0x01,0x01,0x01,0xFD,0x45,0x45,0x45,0x45,0x45,0x45,0x45,0xFF,0x05,0x01,0x01,0x00,};unsigned char code ti[]={ 0x10,0x10,0x10,0xFF,0x90,0x50,0x00,0xFE,0x92,0x92,0x92,0x92,0xFF,0x02,0x00,0x00,0x02,0x42,0x81,0x7F,0x00,0x82,0x42,0x3A,0x42,0x82,0xFE,0x92,0x9A,0xD2,0x42,0x00,};unsigned char code ben[]={ 0x00,0x10,0x10,0x10,0x10,0xF0,0x10,0xFF,0x10,0xF0,0x10,0x10,0x18,0x10,0x00,0x00, 0x10,0x10,0x08,0x04,0x0B,0x08,0x08,0xFF,0x08,0x08,0x0B,0x04,0x08,0x18,0x08,0x00,};unsigned char code wushu[]={0x00,0x40,0x42,0x42,0x42,0x42,0xFE,0x42,0xC2,0x42,0x43,0x42,0x60,0x40,0x00,0x00, 0x00,0x80,0x40,0x20,0x18,0x06,0x01,0x00,0x3F,0x40,0x40,0x40,0x40,0x40,0x70,0x00,unsigned char code shu[]={0x10,0x10,0xD0,0xFF,0x90,0x38,0xC8,0x08,0xC8,0x38,0x90,0x10,0xFF,0x10,0x10,0x00,0x04,0x03,0x00,0xFF,0x20,0x10,0x0C,0x03,0x04,0x18,0x40,0x81,0x7F,0x00,0x00,0x00,};unsigned char code ming[]={0x00,0xFC,0x44,0x44,0x44,0xFE,0x04,0x00,0xFE,0x22,0x22,0x22,0x22,0xFF,0x02,0x00, 0x00,0x0F,0x04,0x04,0x04,0x8F,0x40,0x30,0x0F,0x02,0x02,0x42,0x82,0x7F,0x00,0x00, };unsigned char code jing[]={ 0x20,0x58,0xCF,0x48,0x48,0x24,0xA4,0xAC,0xB5,0xA6,0xB4,0xAC,0xE6,0xB4,0x20,0 x00,0x02,0x02,0x7F,0x22,0x92,0x80,0x4F,0x3A,0x0A,0x0A,0x7A,0x8A,0x8F,0x80,0xE0,0x00, };unsigned char code yy[]={0x08,0x08,0x08,0x88,0x08,0xF8,0x09,0x0E,0x08,0xF8,0x08,0x88,0x08,0x0C,0x08,0x00, 0x00,0x04,0x02,0x41,0x30,0x0F,0x00,0x40,0x80,0x7F,0x00,0x00,0x01,0x06,0x00,0x00, };unsigned char code fei[]={ 0x08,0x88,0x88,0x88,0x88,0xFF,0x00,0x00,0x00,0xFF,0x88,0x88,0xC8,0x8C,0x08,0x00, 0x10,0x10,0x10,0x10,0x10,0xFF,0x00,0x00,0x00,0xFF,0x10,0x10,0x10,0x18,0x10,0x00,};unsigned char code tai[]={0x00,0x40,0x60,0x50,0x48,0x44,0x43,0x40,0x40,0x40,0x48,0x50,0x60,0xC0,0x00,0x00, 0x00,0x00,0x00,0xFE,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0xFF,0x02,0x00,0x00,0x00, };unsigned char code douhao[]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x46,0x2F,0x1F,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };unsigned char code lai[]={0x00,0x08,0x28,0x48,0xC8,0x08,0x08,0xFF,0x08,0x88,0x48,0x68,0x0C,0x88,0x00,0x00, 0x21,0x21,0x11,0x11,0x09,0x05,0x03,0xFF,0x03,0x05,0x09,0x19,0x11,0x31,0x11,0x00,unsigned char code yi[]={ 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xC0,0x80,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};unsigned char code wuti[]={0x40,0x3C,0x10,0xFF,0x90,0xA0,0x10,0x1F,0xF0,0x10,0xF0,0x10,0x10,0xF8,0x10,0x00, 0x02,0x02,0x01,0xFF,0x00,0x10,0x0C,0x43,0x30,0x0E,0x41,0x80,0x40,0x3F,0x00,0x00, };unsigned char code he[]={0x80,0x40,0x20,0xF8,0x07,0x04,0xE4,0x24,0x24,0xF4,0x24,0x04,0xFC,0x06,0x04,0x00, 0x00,0x00,0x00,0xFF,0x00,0x00,0x0F,0x04,0x04,0x0F,0x40,0x80,0x7F,0x00,0x00,0x00, };unsigned char code chu[]={0x00,0x00,0xE0,0x1E,0x10,0x10,0xF0,0x00,0x00,0xFF,0x20,0x40,0x80,0x80,0x00,0x00, 0x82,0x41,0x20,0x1B,0x04,0x1B,0x20,0x40,0x40,0x5F,0x40,0x40,0x40,0x61,0x20,0x00, };unsigned char code re[]={ 0x20,0x24,0x24,0x24,0xAF,0xE4,0xBC,0xA4,0xA4,0xA4,0xAF,0xE4,0xA6,0x34,0x20,0 x00,0x04,0x44,0x32,0x01,0x77,0x84,0x8C,0x94,0xB4,0x84,0x84,0xC7,0x10,0x60,0x00,0x00, };unsigned char code chen[]={0x00,0x40,0x20,0x10,0x08,0x0C,0x00,0x7F,0x00,0x04,0x08,0x10,0x30,0x60,0x00,0x00, 0x40,0x44,0x44,0x44,0x44,0x44,0x44,0x7F,0x44,0x44,0x44,0x44,0x46,0x64,0x40,0x00, };unsigned char code ai[]={0x20,0x20,0x20,0xFF,0x20,0x20,0x10,0xD8,0x94,0x93,0x90,0xD4,0x98,0x30,0x00,0x00, 0x10,0x30,0x10,0x1F,0x08,0x8C,0x85,0x44,0x34,0x0F,0x14,0x24,0x44,0xC6,0x44,0x00, };unsigned char code juhao[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x38,0x7C,0x44,0x44,0x7C,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };void main()InitLCD();ClearScreen(0);Set_line(0);show(1,0,1*16,pu);////1表示左屏显示,0表示从0页开始显示。

12864中文图形点阵液晶显示模块使用说明书

12864中文图形点阵液晶显示模块使用说明书

72us
读出 RAM
的值
1 1 D7
D6
D5
D4
D3
D2
D1
D0
从 内 部 RAM 读 取 数 据 (DDRAM/CGRAM/GDRAM)
72us
指令表 2:(RE=1:扩充指令集)
指令
指令码
RS RW DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
说明
执行 时间 (540K HZ)
功能:设定 CGRAM 地址到地址计数器(AC),需确定扩充指令中 SR=0(卷动地址或 RAM 地址选择)
地址
设定 CGRAM 地址到地址计数器(AC)
1 AC5 AC4 AC3 AC2 AC1 AC0 需确定扩充指令中 SR=0(卷动地址或 72us RAM 地址选择)
设定 DDRAM 0 0 1 AC6 AC5 AC4 AC3 AC2 AC1 AC0 设定 DDRAM 地址到地址计数器(AC) 72us
I/O
DB5
I/O
DB6
I/O
DB7
I/O
PSB
I
NC
-
/RST
I
VEE
-
LED+
-
LED-
-
说明
电源地
逻辑电源正(+5V)
LCD 对比度调节电压
并行模式时选择数据或指令
H: 数据 L: 指令
串行模式时选择模块与否
H: 选择 L: 不选择
并行模式时控制读写
H: 读
L: 写
串行模式时输入数据
并行模式时使能端
L
L
L
H
DL
X
RE
X

12864串行显示中文讲解

12864串行显示中文讲解

12864串行显示中文,按键选择显示页面,并且可调数值。

单片机P1口接矩阵按键,其它接口按程序中定义去接只需要接12864LCD上GND VCC RS RW E PSB RST A K程序如下/********************************12864.h头文件*******************************/ #ifndef _12864_h#define _12864_h/*****包含头文件**************/#include<reg51.h>/********定义I/0口**********/#define GPIO_KEY P1sbit LCD12864_SCLK = P2^7; //Esbit LCD12864_SID = P2^5; //RWsbit LCD12864_CS = P2^6; //RSsbit LCD12864_RET= P2^0;sbit LCD12864_PSB =P2^2;/*声明全局变量*/extern unsigned char keyvalue;/******声明全局函数*********/void Delay1ms(unsigned int); //声明延时函数unsigned char KeyDown(void);void LCD_sendbyte(unsigned char);void WrCom(unsigned char);void WrDat(unsigned char);void LcdInit(void);//void Print(unsigned char);void SetAddress( unsigned char,unsigned char );void DisplayString(unsigned char x ,unsigned char y,unsigned char *add);#endif/********************************12864.C*************************************/ #include"12864.h"#include<reg51.h>#include"string.h"//#define LCM_ST7920_FIRST_LINE_ADDRESS 0x80//#define LCM_ST7920_SECOND_LINE_ADDRESS 0x90//#define LCM_ST7920_THIRD_LINE_ADDRESS 0x88//#define LCM_ST7920_FOURTH_LINE_ADDRESS 0x98/*定义全局变量*/unsigned char keyvalue=0;/****************************************************************************** ** 函数名: Delay1ms* 函数功能: 延时函数,延时1ms* 输入: c* 输出 e : 无* 说名: 该函数是在12MHZ晶振下,12分频单片机的延时。

12864汉字显示

12864汉字显示

/***********************************************************实验名称:LCD12864显示技术***********************************************************/#include <stdio.h>#include <math.h>#include <reg52.h>#include <string.h>/******************************************************************/ /* 定义数组*/ /******************************************************************/ unsigned char code IC_DA T[];unsigned char code pic1[];unsigned char code pic2[];unsigned char code pic3[];/******************************************************************/ /* 定义接口信息*/ /******************************************************************/ sbit RS =P2^0;sbit WRD=P2^1;sbit E= P2^2;sbit PSB=P2^3;sbit RES=P2^5;/******************************************************************/ /* 函数声明*/ /******************************************************************/ void TransferData(char data1,bit DI);void display(void);void display_grapic(void);void delayms(unsigned int n);void DisplayLine(unsigned char line1,unsigned char line2);void DisplayGraphic(unsigned char code *adder);void delay(unsigned int m);void lcd_mesg(unsigned char code *adder1);unsigned char code IC_DA T[]={"广州研展电子科技"" "" 有限公司""开发工具专业厂商"};unsigned char code IC_DA T2[]={" YZ200 V2.0 "" 知识改变命运"" 单片机开发箱"" 学习成就未来"};/******************************************************************//* 液晶初始化-字库*//******************************************************************/void initinal(void) //LCD字库初始化程序{delay(40); //大于40MS的延时程序PSB=1; //设置为8BIT并口工作模式delay(1); //延时RES=0; //复位delay(1); //延时RES=1; //复位置高delay(10);TransferData(0x30,0); //Extended Function Set :8BIT设置,RE=0: basic instruction set, G=0 :graphic display OFFdelay(100); //大于100uS的延时程序TransferData(0x30,0); //Function Setdelay(37); ////大于37uS的延时程序TransferData(0x08,0); //Display on Controldelay(100); //大于100uS的延时程序TransferData(0x10,0); //Cursor Display Control光标设置delay(100); //大于100uS的延时程序TransferData(0x0C,0); //Display Control,D=1,显示开delay(100); //大于100uS的延时程序TransferData(0x01,0); //Display Cleardelay(10); //大于10mS的延时程序TransferData(0x06,0); //Enry Mode Set,光标从右向左加1位移动delay(100); //大于100uS的延时程序}/******************************************************************//* 液晶初始化-图形*//******************************************************************/void initina2(void) //LCD显示图片(扩展)初始化程序{delay(40); //大于40MS的延时程序PSB=1; //设置为8BIT并口工作模式delay(1); //延时RES=0; //复位delay(1); //延时RES=1; //复位置高delay(10);TransferData(0x36,0); //Extended Function Set RE=1: extended instructiondelay(100); //大于100uS的延时程序TransferData(0x36,0); //Extended Function Set:RE=1: extended instruction setdelay(37); ////大于37uS的延时程序TransferData(0x3E,0); //EXFUNCTION(DL=8BITS,RE=1,G=1)delay(100); //大于100uS的延时程序TransferData(0x01,0); //CLEAR SCREENdelay(100); //大于100uS的延时程序}/******************************************************************//* 主程序*//******************************************************************/void main(void){while(1){initina2(); //调用LCD显示图片(扩展)初始化程序DisplayGraphic(pic2); //显示图片2delayms(200);DisplayGraphic(pic3); //显示图片3delayms(200);initinal(); //调用LCD字库初始化程序delay(100); //大于100uS的延时程序lcd_mesg(IC_DA T); //显示中文汉字1delayms(240);delayms(240);initinal(); //调用LCD字库初始化程序delay(100); //大于100uS的延时程序lcd_mesg(IC_DA T2); //显示中文汉字2delayms(240);delayms(240);}}/******************************************************************//* 函数声明*//******************************************************************/void lcd_mesg(unsigned char code *adder1){unsigned char i;TransferData(0x80,0); //Set Graphic Display RAM Addressdelay(100);for(i=0;i<32;i++){TransferData(*adder1,1);adder1++;}TransferData(0x90,0); //Set Graphic Display RAM Addressdelay(100);for(i=32;i<64;i++){TransferData(*adder1,1);adder1++;}}/******************************************************************//* 函数声明*//******************************************************************/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) //延时10×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++);}/******************************************************************/ /* 函数声明*/ /******************************************************************/ void DisplayGraphic(unsigned char code *adder){int i,j;//*******显示上半屏内容设置for(i=0;i<32;i++) //{TransferData((0x80 + i),0); //SET 垂直地址VERTICAL ADDTransferData(0x80,0); //SET 水平地址HORIZONTAL ADDfor(j=0;j<16;j++){TransferData(*adder,1);adder++;}}//*******显示下半屏内容设置for(i=0;i<32;i++) //{TransferData((0x80 + i),0); //SET 垂直地址VERTICAL ADDTransferData(0x88,0); //SET 水平地址HORIZONTAL ADDfor(j=0;j<16;j++){TransferData(*adder,1);adder++;}}}unsigned char code pic2[]={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, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x1F,0xFF,0x81,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x1F,0xFF,0x81,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x18,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x08,0x00,0x00,0x00,0x03,0xC0,0x1F,0xFF,0x80,0x00,0x00,0x04,0x07,0x81,0xE0,0x10,0x10,0x03,0xC0,0x30,0x03, 0xC0,0x1F,0xFF,0x80,0x00,0x00,0x0C,0x0C,0xC3,0x30,0x08,0x20,0x0C,0xE0,0x70,0x03, 0xC0,0x18,0x01,0x87,0xFF,0xFE,0x3C,0x18,0x66,0x18,0x04,0x40,0x0C,0x60,0x70,0x03, 0xC0,0x1F,0xFF,0x87,0xFF,0xFE,0x0C,0x18,0x66,0x18,0x02,0x80,0x18,0x00,0xB0,0x03, 0xC0,0x1F,0xFF,0x80,0x06,0x00,0x0C,0x18,0x66,0x18,0x01,0x00,0x1B,0x81,0x30,0x03, 0xC0,0x01,0x98,0x00,0x06,0x00,0x0C,0x00,0xE3,0x30,0x02,0x80,0x1C,0xC1,0x30,0x03, 0xC0,0x19,0x99,0x80,0x66,0x60,0x0C,0x00,0xC1,0xE0,0x04,0x40,0x18,0x62,0x30,0x03, 0xC0,0x19,0x99,0x80,0x66,0x30,0x0C,0x01,0x83,0x30,0x08,0x20,0x18,0x66,0x30,0x03,0xC0,0x0D,0x9B,0x00,0xC6,0x38,0x0C,0x03,0x06,0x18,0x10,0x10,0x18,0x67,0xFC,0x03, 0xC0,0x0D,0x9B,0x01,0xC6,0x1C,0x0C,0x06,0x06,0x18,0x20,0x08,0x18,0x60,0x30,0x03, 0xC0,0x01,0x98,0x03,0x86,0x0C,0x0C,0x0C,0x06,0x18,0x00,0x00,0x08,0x60,0x30,0x03, 0xC0,0x7F,0xFF,0xE3,0x06,0x00,0x0C,0x18,0x03,0x30,0x00,0x00,0x0C,0xC0,0x30,0x03, 0xC0,0x7F,0xFF,0xE0,0x1E,0x00,0x0C,0x1F,0xE1,0xE0,0x00,0x00,0x07,0x80,0x30,0x03, 0xC0,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x18,0x00,0x00,0x00,0x06,0x0C,0x03, 0xC3,0xFF,0xFC,0x3F,0xF0,0x80,0x0C,0x00,0x3F,0x18,0x01,0xFF,0xFE,0x06,0x0C,0x03, 0xC3,0xFF,0xFC,0x3F,0xF1,0x80,0x0F,0xFC,0x3F,0x18,0x01,0xFF,0xFE,0x06,0x0C,0x03, 0xC3,0x0C,0x0C,0x0C,0xC3,0x00,0x0F,0xFC,0x33,0x7F,0xE1,0x86,0x06,0x06,0x0C,0x03, 0xC3,0x1F,0xCC,0x0C,0xC6,0x00,0x0C,0x00,0x33,0x7F,0xE1,0x8F,0xE6,0x06,0x0C,0x03, 0xC3,0x3F,0xCC,0x0C,0xCC,0x00,0x0C,0x00,0x36,0x30,0x01,0x9F,0xE6,0x07,0xFF,0xE3, 0xC3,0x79,0x8C,0x0C,0xC8,0x00,0xFF,0xF0,0x36,0x36,0x01,0xBC,0xC6,0x07,0xFF,0xE3, 0xC3,0x6F,0x0C,0x7F,0xF0,0xC0,0xFF,0xF0,0x36,0x66,0x01,0xB7,0x86,0x06,0x00,0x03, 0xC3,0x0F,0x0C,0x7F,0xF1,0x80,0xC0,0x30,0x36,0x7F,0xC1,0x87,0x86,0x06,0x00,0x03, 0xC3,0x79,0xEC,0x0C,0xC3,0x00,0xC0,0x30,0x33,0x7F,0xC1,0xBC,0xF6,0x06,0x00,0x03, 0xC3,0x76,0xEC,0x0C,0xC6,0x00,0xC0,0x30,0x33,0x06,0x01,0xBB,0x76,0x07,0xFF,0x03, 0xC3,0x07,0x0C,0x0C,0xCC,0x20,0xFF,0xF0,0x33,0x06,0x01,0x83,0x86,0x07,0xFF,0x03,0xC3,0x03,0x0C,0x18,0xC8,0x60,0xFF,0xF0,0x3F,0x06,0x01,0x81,0x86,0x06,0x03,0x03, 0xC3,0x1C,0x0C,0x18,0xC0,0xC0,0x00,0x00,0x3E,0xFF,0xE1,0x8E,0x06,0x06,0x03,0x03, 0xC3,0x1F,0x0C,0x18,0xC1,0x81,0xB1,0x8C,0x30,0xFF,0xE1,0x8F,0x86,0x06,0x03,0x03, 0xC3,0x03,0x0C,0x30,0xC7,0x01,0xB1,0x8C,0x30,0x06,0x01,0x81,0x86,0x0C,0x03,0x03, 0xC3,0xFF,0xFC,0x70,0xDE,0x03,0x18,0xC6,0x30,0x06,0x01,0xFF,0xFE,0x0C,0x03,0x03, 0xC3,0xFF,0xFC,0x20,0x18,0x03,0x18,0xC6,0x30,0x06,0x01,0xFF,0xFE,0x18,0x03,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 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,};unsigned char code pic3[]={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, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC3,0x02,0x0E,0x1C,0x08,0xF8,0x67,0xE3,0x87,0x0C,0x08,0x38,0x70,0x23,0xE1,0x83, 0xC4,0x8E,0x11,0x22,0x18,0x80,0x90,0x24,0x48,0x92,0x38,0x44,0x88,0x62,0x02,0x43, 0xC8,0x42,0x11,0x22,0x28,0x81,0x00,0x24,0x48,0xA1,0x08,0x44,0x88,0xA2,0x04,0x03, 0xC8,0x42,0x01,0x02,0x28,0xF1,0xE0,0x44,0x48,0xA1,0x08,0x04,0x08,0xA3,0xC7,0x83, 0xC8,0x42,0x02,0x0C,0x48,0x89,0x10,0x43,0x88,0xA1,0x08,0x08,0x31,0x22,0x24,0x43, 0xC8,0x42,0x04,0x02,0x88,0x09,0x10,0x44,0x47,0xA1,0x08,0x10,0x0A,0x20,0x24,0x43, 0xC8,0x42,0x08,0x22,0xFC,0x89,0x10,0x44,0x40,0xA1,0x08,0x20,0x8B,0xF2,0x24,0x43, 0xC4,0x82,0x10,0x22,0x08,0x89,0x10,0x84,0x49,0x12,0x08,0x40,0x88,0x22,0x24,0x43, 0xC3,0x02,0x1F,0x1C,0x08,0x70,0xE0,0x83,0x86,0x0C,0x08,0x7C,0x70,0x21,0xC3,0x83, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xCF,0xC7,0x0E,0x18,0x10,0x70,0xE0,0x47,0xC3,0x3F,0x1C,0x38,0x60,0x41,0xC3,0x83, 0xC0,0x48,0x91,0x24,0x70,0x89,0x10,0xC4,0x04,0x81,0x22,0x44,0x91,0xC2,0x24,0x43, 0xC0,0x48,0x91,0x42,0x10,0x89,0x11,0x44,0x08,0x01,0x22,0x45,0x08,0x42,0x24,0x43, 0xC0,0x88,0x91,0x42,0x10,0x08,0x11,0x47,0x8F,0x02,0x22,0x45,0x08,0x40,0x20,0x43, 0xC0,0x87,0x11,0x42,0x10,0x10,0x62,0x44,0x48,0x82,0x1C,0x45,0x08,0x40,0x41,0x83, 0xC0,0x88,0x8F,0x42,0x10,0x20,0x14,0x40,0x48,0x82,0x22,0x3D,0x08,0x40,0x80,0x43, 0xC0,0x88,0x81,0x42,0x10,0x41,0x17,0xE4,0x48,0x82,0x22,0x05,0x08,0x41,0x04,0x43, 0xC1,0x08,0x92,0x24,0x10,0x81,0x10,0x44,0x48,0x84,0x22,0x48,0x90,0x42,0x04,0x43, 0xC1,0x07,0x0C,0x18,0x10,0xF8,0xE0,0x43,0x87,0x04,0x1C,0x30,0x60,0x43,0xE3,0x83, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x8F,0x86,0x7E,0x38,0x70,0xC0,0x83,0x87,0x02,0x3E,0x19,0xF8,0xE1,0xC3,0x03, 0xC1,0x88,0x09,0x02,0x44,0x89,0x23,0x84,0x48,0x86,0x20,0x24,0x09,0x12,0x24,0x83, 0xC2,0x88,0x10,0x02,0x44,0x8A,0x10,0x84,0x48,0x8A,0x20,0x40,0x09,0x12,0x28,0x43, 0xC2,0x8F,0x1E,0x04,0x44,0x8A,0x10,0x80,0x40,0x8A,0x3C,0x78,0x11,0x12,0x28,0x43, 0xC4,0x88,0x91,0x04,0x38,0x8A,0x10,0x80,0x83,0x12,0x22,0x44,0x10,0xE2,0x28,0x43, 0xC8,0x80,0x91,0x04,0x44,0x7A,0x10,0x81,0x00,0xA2,0x02,0x44,0x11,0x11,0xE8,0x43, 0xCF,0xC8,0x91,0x04,0x44,0x0A,0x10,0x82,0x08,0xBF,0x22,0x44,0x11,0x10,0x28,0x43, 0xC0,0x88,0x91,0x08,0x44,0x91,0x20,0x84,0x08,0x82,0x22,0x44,0x21,0x12,0x44,0x83, 0xC0,0x87,0x0E,0x08,0x38,0x60,0xC0,0x87,0xC7,0x02,0x1C,0x38,0x20,0xE1,0x83,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC1,0x07,0x0E,0x04,0x7C,0x33,0xF1,0xC3,0x86,0x04,0x1C,0x38,0x11,0xF0,0xCF,0xC3, 0xC7,0x08,0x91,0x0C,0x40,0x48,0x12,0x24,0x49,0x1C,0x22,0x44,0x31,0x01,0x20,0x43, 0xC1,0x08,0x91,0x14,0x40,0x80,0x12,0x24,0x50,0x84,0x22,0x44,0x51,0x02,0x00,0x43, 0xC1,0x00,0x81,0x14,0x78,0xF0,0x22,0x24,0x50,0x84,0x02,0x04,0x51,0xE3,0xC0,0x83, 0xC1,0x01,0x06,0x24,0x44,0x88,0x21,0xC4,0x50,0x84,0x04,0x18,0x91,0x12,0x20,0x83, 0xC1,0x02,0x01,0x44,0x04,0x88,0x22,0x23,0xD0,0x84,0x08,0x05,0x10,0x12,0x20,0x83, 0xC1,0x04,0x11,0x7E,0x44,0x88,0x22,0x20,0x50,0x84,0x10,0x45,0xF9,0x12,0x20,0x83, 0xC1,0x08,0x11,0x04,0x44,0x88,0x42,0x24,0x89,0x04,0x20,0x44,0x11,0x12,0x21,0x03, 0xC1,0x0F,0x8E,0x04,0x38,0x70,0x41,0xC3,0x06,0x04,0x3E,0x38,0x10,0xE1,0xC1,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03, 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,};。

玩转12864液晶--显示字符

玩转12864液晶--显示字符

在我们常用的人机交互显示界面中,除了数码管,LED,以及我们之前已经提到的LCD1602之外,还有一种液晶屏用的比较多。

相信接触过单片机的朋友都知道了,那就是12864液晶。

顾名思义,12864表示其横向可以显示128个点,纵向可以显示64个点。

我们常用的12864液晶模块中有带字库的,也有不带字库的,其控制芯片也有很多种,如KS0108T6963,ST7920等等。

在这里我们以ST7920为主控芯片的12864液晶屏来学习如何去驱动它。

(液晶屏采用金鹏的OCMJ4X8C)关于这个液晶屏的更多信息,请参考它的DATASHEET,附件中有下载。

我们先来了解一下它的并行连接情况。

下面是电路连接图从上面的图可以看出,液晶模块和单片机的连接除了P0口的8位并行数据线之外,还有RS,RW,E等几根线。

其中R/S是指令和数据寄存器的选择控制线(串行模式下为片选),R/W是读写控制线(串行模式下是数据线),E是使能线(串行模式下为时钟线)。

通过这几根控制线和数据线,再结合它的时序图,我们就可以编写出相应的驱动程序啦。

看看并行模式下的写时序图:根据这个时序图,我们就可以写出写数据或者写命令到LCD12864液晶的子程序。

读时序图如下:根据这个时序图我们就可以从LCD12864液晶模块内部RAM中读出相应的数据,我们的忙检测函数就是根据这个时序图写出来的。

以及后面章节中讲的画点函数等都要用到读时序。

有了这两个时序图,然后我们再看看OCMJ4X8C的相关指令集,就可以编写出驱动程序了。

这里要注意的是指令集分为基本指令集和扩充指令集,其中扩充指令集主要是与绘图相关,在此后的章节中会有相应的介绍。

下面让我们根据这些编写出它的驱动程序吧。

我的硬件测试条件为:STC89C516(11.0592MHz) + OCMJ4X8C实际显示效果图片如下:程序部分如下,请结合液晶模块的DATASHEET看程序,这样能够更加快速的弄懂程序的流程。

12864汉字和图片的显示

12864汉字和图片的显示

12864汉字和图片的显示课程设计报告书设计题目:12864汉字和图片的显示课程名称:单片机快速入门系部:电子信息系专业:应用电子技术班级:电子0901姓名:组长:学号:成绩:2011年6月16日目录任务安排 (3)一、项目介绍 (3)1.1 设计内容 (3)1.2 设计要求 (3)1.3 系统主要功能 (4)二、硬件设计 (4)2.1 原理电路图 (4)2.2主要元件功能说明 (5)三、系统软件设计 (10)3.1 分析论证 (10)3.2 程序流程图 (12)3.3 源程序清单 (13)四、个人心得 (19)五、结束语 (20)六、参考文献 (21)七、12864汉字和图片的显示原理图 (21)任务安排一、项目介绍1.1 设计内容利用单片机和12864液晶显示屏通过按键功能实现汉字和图片的显示1.2 设计要求(1)在12864上第一次显示汉字“安徽财贸职业学院大学城翡翠路900/doc/dd174fd133d4b14e852468a7.ht ml ”(2)在12864上第二次显示汉字“单片机实训周6月11日星期六”(3)第三次显示图片:服装,帽子,鞋,皮包等(4)第四次显示汉字:“这就是我们小组的设计方案谢谢欣赏”1.3系统主要功能:12864LCD指令系统及时序该类液晶显示模块(表1-1)控制信号控制代码指令名称R/W RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 显示开关0 0 0 0 1 1 1 1 1 1/0 起始行设置0 0 1 1 X X X X X X 页设置0 0 1 0 1 1 1 X X X 列地址设置0 0 0 1 X X X X X X 读状态 1 0 BUSY 0 ON/OFF RST 0 0 0 0 写数据0 1 写数据读数据 1 1 读数据二、硬件设计2.1 原理电路图12864显示屏(图2-1a)独立按键原理图(图2-1b)2.2主要元件功能说明1)12864显示屏内部功能器件及相关功能如下指令寄存器(IR): IR是用于寄存指令码,与数据寄存器数据相对应。

12864翻页显示汉字源程序

12864翻页显示汉字源程序

12864翻页显示汉字源程序#include#include#define GDM12864ADataPort P1 //LCD数据线sbit DI=P2^2; // 数据\指令选择sbit RW=P2^1; // 读\写选择sbit EN=P2^0; // 读\写使能sbit cs1=P2^4; // 片选1sbit cs2=P2^3; // 片选2sbit UP=P0^0;//定义UPsbit DOWN=P0^1;//定义DOWNsbit TEST=P3^0;//定义DOWNunsigned char i,j,t;static int nxx;int t0,t1,t2,t3,tx,k,k0,k1,k2,k3;//*--------函数列表-------//状态检查void CheckState(){unsigned char dat;DI=0;RW=1;do{GDM12864ADataPort=0x00;EN=1;dat=GDM12864ADataPort;EN=0;dat=0x80 & dat; //仅当第7位为0时才可操作(判别busy信号) }while(!(dat==0x00));}/*-----------------------------------------------------------------------------------------------------*///向LCD发送命令//command :命令SendCommandToLCD(unsigned char command){CheckState();RW=0;GDM12864ADataPort=command;EN=1; EN=0;}/*----------------------------------------------------------------------------------------------------*///写显示数据//dat:显示数据void WriteByte(unsigned char dat){CheckState();DI=1; RW=0;GDM12864ADataPort=dat;EN=1; EN=0;}/*----------------------------------------------------------------------------------------------------*///读显示数据unsigned char ReadByte(){unsigned char dat;CheckState();DI=1; RW=1;GDM12864ADataPort=0xff;EN=1; dat=GDM12864ADataPort; EN=0;return(dat);}/*----------------------------------------------------------------------------------------------------*///设定行地址(页)--X 0-7void SetLine(unsigned char line){line=line & 0x07; // 0<=line<=7line=line|0xb8; //1011 1xxxSendCommandToLCD(line);}/*----------------------------------------------------------------------------------------------------*///设定列地址--Y 0-63void SetColumn(unsigned char column){column=column &0x3f; // 0=<column<=63column=column | 0x40; //01xx xxxxSendCommandToLCD(column);}/*----------------------------------------------------------------------------------------------------*///设定显示开始行--XXvoid SetStartLine(unsigned char startline) //0--63{startline=startline & 0x07;startline=startline|0xc0; //1100 0000SendCommandToLCD(startline);}/*----------------------------------------------------------------------------------------------------*///开关显示void SetOnOff(unsigned char onoff){onoff=0x3e | onoff; //0011 111xSendCommandToLCD(onoff);}/*---------------------------------------------------------------------------------------------------*///选择屏幕//screen: 0-全屏,1-左屏,2-右屏void SelectScreen(unsigned char screen){ //cs1: 1--左; cs2: 1--右switch(screen){ case 0: cs1=0;//全屏_nop_(); _nop_(); _nop_();cs2=0;_nop</column<=63_(); _nop_(); _nop_();break;case 1: cs1=0;//左屏_nop_(); _nop_(); _nop_();cs2=1;_nop_(); _nop_(); _nop_();break;case 2: cs1=1;//右屏_nop_(); _nop_(); _nop_();cs2=0;_nop_(); _nop_(); _nop_();break;}}/*---------------------------------------------------------------------------------------------------*///延时GDM12864delay(){unsigned int i=500;while(i--) {;}}/*---------------------------------------------------------------------------------------------------*///清屏//screen: 0-全屏,1-左屏,2-右void ClearScreen(unsigned char screen){ unsigned char i,j;SelectScreen(screen);for(i=0;i<8;i++){SetLine(i);for(j=0;j<128;j++){WriteByte(0x00);}}}/*---------------------------------------------------------------------------------------------------*///初始化LCDvoid InitLCD(){ unsigned char i=250; //延时while(i--);SelectScreen(0);SetOnOff(0); //关显示//ClearScreen(0);//清屏SelectScreen(0);SetOnOff(1); //开显示SelectScreen(0);SetStartLine(0); //开始行:0}/*----------------------------------------------------------------------------------------------------*//*----------------------------------------------------------------------------------------------*/unsigned char code ASC[]={/*.--0x2E */0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x00,/*'/'--0x2F */0x00,0x00,0x00,0x80,0xC0,0x60,0x30,0x00, 0x0C,0x06,0x03,0x01,0x00,0x00,0x00,0x00,/*0--0x30 */0xF8,0xFC,0x04,0xC4,0x24,0xFC,0xF8,0x00, 0x07,0x0F,0x09,0x08,0x08,0x0F,0x07,0x00,/*1--0x31 */0x00,0x10,0x18,0xFC,0xFC,0x00,0x00,0x00, 0x00,0x08,0x08,0x0F,0x0F,0x08,0x08,0x00,/*2--0x32 */0x08,0x0C,0x84,0xC4,0x64,0x3C,0x18,0x00, 0x0E,0x0F,0x09,0x08,0x08,0x0C,0x0C,0x00,/*3--0x33 */0x08,0x0C,0x44,0x44,0x44,0xFC,0xB8,0x00, 0x04,0x0C,0x08,0x08,0x08,0x0F,0x07,0x00,/*4--0x34 */0xC0,0xE0,0xB0,0x98,0xFC,0xFC,0x80,0x00, 0x00,0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,/*5--0x35 */0x7C,0x7C,0x44,0x44,0xC4,0xC4,0x84,0x00, 0x04,0x0C,0x08,0x08,0x08,0x0F,0x07,0x00,/*6--0x36 */0xF0,0xF8,0x4C,0x44,0x44,0xC0,0x80,0x00,0x07,0x0F,0x08,0x08,0x08,0x0F,0x07,0x00,/*7--0x37 */0x0C,0x0C,0x04,0x84,0xC4,0x7C,0x3C,0x00,0x00,0x00,0x0F,0x0F,0x00,0x00,0x00,0x00,/*8--0x38 */0xB8,0xFC,0x44,0x44,0x44,0xFC,0xB8,0x00,0x07,0x0F,0x08,0x08,0x08,0x0F,0x07,0x00,/*9--0x39 */0x38,0x7C,0x44,0x44,0x44,0xFC,0xF8,0x00,0x00,0x08,0x08,0x08,0x0C,0x07,0x03,0x00};/*----------------------------------------------------------------------------------------------*/#define CB6AB0x0000 /*东 */#define CC4CF CB6AB+32 /*南 *///从左到右从上到下,纵向8点下高位分粗细体unsigned char code Hztable[]={//" "0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" "0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //"唐"0x00,0x00,0x00,0xFE,0xFC,0x84,0xA4,0xA4, 0xA5,0xFF,0xFE,0xA4,0xE4,0xF6,0xA4,0x80, 0x00,0x80,0x40,0x3F,0x1F,0xFC,0xFA,0x4A, 0x4A,0x4F,0x4F,0x4A,0xFB,0xFF,0x10,0x00, //0x00,0x00,0xFC,0x44,0x54,0x54,0x54,0x55, //0xFE,0x54,0x54,0x54,0xF6,0x44,0x40,0x00, //0x40,0x30,0x0F,0x00,0xFD,0x45,0x45,0x45, //0x47,0x45,0x45,0x45,0xFD,0x00,0x00,0x00,//"山",0x00,0x00,0xC0,0x80,0x00,0x00,0x00,0x00, 0xFE,0xFC,0x00,0x00,0x00,0x00,0xC0,0x80, 0x00,0x00,0xFF,0x7F,0x20,0x20,0x20,0x20, 0x3F,0x3F,0x20,0x20,0x20,0x20,0xFF,0x7F,//"华",0x00,0x40,0x20,0x30,0xFC,0xF7,0x02,0x80, 0x60,0xFF,0xFE,0x18,0x0E,0xC4,0x00,0x00, 0x00,0x08,0x08,0x08,0x0B,0x09,0x08,0xFE, 0xFE,0x09,0x0B,0x0B,0x0B,0x0B,0x0D,0x08,//"光",0x00,0x00,0x80,0x82,0xBC,0x98,0x80,0xFF, 0xFE,0x80,0xE0,0xB8,0x9E,0xC4,0x80,0x00,0x00,0x80,0x80,0x40,0x60,0x38,0x1F,0x07, 0x00,0x7F,0xFF,0xC0,0xC0,0xC0,0xF0,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,0x00,0x00,0x00,0x00,0x00,//"自",0x00,0x00,0x00,0xFC,0xF8,0x88,0x8C,0x8F, 0x8A,0x88,0x88,0x88,0xF8,0xFC,0x08,0x00, 0x00,0x00,0x00,0xFF,0x7F,0x44,0x44,0x44, 0x44,0x44,0x44,0x44,0xFF,0x7F,0x00,0x00,//"力",0x00,0x00,0x10,0x10,0x10,0x10,0xFF,0xFE, 0x10,0x10,0x10,0x10,0xF0,0xF8,0x10,0x00, 0x00,0x80,0x40,0x60,0x38,0x1F,0x07,0x00, 0x00,0x40,0x40,0xE0,0x7F,0x1F,0x00,0x00,//"更",0x00,0x02,0x02,0xFE,0xFA,0xAA,0xAA,0xAA, 0xFE,0xFE,0xAA,0xAA,0xFA,0xFE,0x0B,0x02, 0x00,0x80,0x80,0x41,0x41,0x22,0x34,0x1C, 0x0F,0x1B,0x30,0x60,0x61,0xC1,0xC0,0x40,//"生",0x00,0x80,0x60,0x38,0x1E,0x14,0x10,0x10, 0xFF,0xFE,0x10,0x10,0x90,0x18,0x10,0x00, 0x00,0x40,0x40,0x40,0x41,0x41,0x41,0x41, 0x7F,0x7F,0x41,0x41,0x41,0x41,0x60,0x40,//"艰",0x00,0x04,0x34,0xC4,0xE4,0x7E,0x1C,0xFF, 0xFE,0x92,0x92,0x92,0xFE,0xFF,0x02,0x00, 0x00,0x20,0x18,0x0E,0x03,0x1E,0x4C,0xFF, 0x7F,0x61,0x36,0x1C,0x39,0x6E,0xE4,0x40,//"苦",0x00,0x84,0x84,0x84,0x84,0x9F,0x9F,0xE4, 0xE4,0x9F,0x9F,0x84,0x84,0xC6,0x84,0x00, 0x00,0x00,0x00,0xFE,0x7C,0x44,0x44,0x47, 0x47,0x44,0x44,0xFC,0x7E,0x04,0x00,0x00,//"奋",0x00,0x00,0x88,0x88,0xC8,0x68,0x38,0x1F, 0x0E,0x18,0x38,0x68,0x4C,0xC8,0x80,0x80, 0x00,0x01,0x00,0xFF,0xFF,0x49,0x49,0x7F, 0x7F,0x49,0x49,0xFF,0xFF,0x00,0x01,0x00,//"斗",0x00,0x00,0x00,0x20,0xE0,0xC6,0x9C,0x08, 0x00,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x04,0x04,0x04,0x05,0x04,0x04,0x04,0xFF,0x7F,0x02,0x02,0x02,0x03,0x02, //"科",0x00,0x24,0xA4,0xFE,0xFE,0xA3,0x22,0xC0, 0x8C,0x38,0x10,0xFF,0xFE,0x00,0x00,0x00, 0x00,0x0C,0x03,0xFF,0x7F,0x01,0x0B,0x08, 0x0B,0x05,0x04,0xFF,0x7F,0x02,0x03,0x02,//"技",0x00,0x10,0x10,0xFF,0xFE,0x10,0x98,0x48, 0xC8,0x48,0x7F,0x7E,0xC8,0xE8,0x4C,0x08, 0x00,0x0C,0x46,0xFF,0x7F,0x01,0x80,0x40, 0x61,0x37,0x1C,0x1E,0x37,0x61,0xE0,0x40,//"创",0x00,0x80,0x40,0xE0,0xB8,0x9E,0x8F,0x9A, 0xF0,0xA0,0x00,0xF0,0xF0,0x00,0xFF,0xFE, 0x00,0x00,0x00,0x7F,0xFF,0xC0,0xC4,0xCF, 0xE7,0x40,0x00,0x03,0x23,0x40,0xFF,0x7F,//"新",0x00,0x44,0x4C,0x7C,0xD7,0xE6,0x7C,0x5C, 0x44,0xFE,0xFC,0x46,0xC2,0xC3,0x62,0x40, 0x00,0x22,0x1A,0x4E,0xFF,0x7F,0x0E,0x9A, 0x60,0x3F,0x1F,0x00,0xFF,0xFF,0x00,0x00,//"精",0x00,0x26,0xA8,0xFF,0xFE,0xA8,0x66,0x44, 0xD4,0x54,0x7F,0x7E,0x54,0xD6,0x64,0x40, 0x00,0x0C,0x03,0xFF,0x7F,0x01,0x06,0x00, 0xFF,0x7F,0x15,0x55,0xFF,0x7F,0x01,0x00,//"益",0x00,0x08,0x08,0x88,0xC9,0x6E,0x3C,0x18, 0x08,0x1C,0x3E,0x6B,0xCA,0x88,0x8C,0x08, 0x00,0x82,0x81,0xFF,0xFE,0x82,0xFE,0xFE, 0x82,0xFE,0xFE,0x82,0xFE,0xFF,0x83,0x81,//"求",0x00,0x00,0x08,0x68,0xC8,0x88,0x08,0xFF, 0xFE,0x88,0xCB,0x7E,0x2C,0x08,0x00,0x00, 0x00,0x10,0x70,0x38,0x0D,0x26,0x41,0xFF, 0x7F,0x03,0x06,0x1C,0x38,0x70,0x20,0x00,//"精",0x00,0x26,0xA8,0xFF,0xFE,0xA8,0x66,0x44, 0xD4,0x54,0x7F,0x7E,0x54,0xD6,0x64,0x40, 0x00,0x0C,0x03,0xFF,0x7F,0x01,0x06,0x00, 0xFF,0x7F,0x15,0x55,0xFF,0x7F,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, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //" "0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//"华",0x10,0xFF,0x08,0x04,0x06,0xC0,0x00,0x00, 0x04,0x04,0x04,0x04,0x05,0x04,0x04,0xFF, 0x04,0x04,0x05,0x05,0x05,0x05,0x04,0x00,//"光",0x40,0x40,0x42,0x44,0x58,0xC0,0x40,0x7F, 0x40,0xC0,0x50,0x48,0x46,0x64,0x40,0x00, 0x00,0x80,0x40,0x20,0x18,0x07,0x00,0x00,0x00,0x3F,0x40,0x40,0x40,0x40,0x70,0x00,//"研",0x82,0x42,0xF2,0x4E,0x43,0xC2,0x80,0x82, 0xFE,0x82,0x82,0x82,0xFF,0x82,0x80,0x00, 0x00,0x00,0x3F,0x10,0x10,0x5F,0x20,0x18, 0x07,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//"发",0x00,0x10,0x18,0x16,0x10,0x90,0xF0,0x9F, 0x90,0x90,0x92,0x94,0x10,0x18,0x10,0x00, 0x40,0x20,0x90,0x88,0x46,0x41,0x23,0x14, 0x08,0x14,0x22,0x21,0x40,0xC0,0x40,0x00,//"所",0x00,0x00,0xFC,0x24,0x24,0x22,0xE3,0x02, 0xFC,0x44,0x44,0x42,0xC3,0x62,0x40,0x00, 0x40,0x20,0x1F,0x02,0x02,0x42,0x27,0x10, 0x0F,0x00,0x00,0x00,0xFF,0x00,0x00,0x00, //" "0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/*--------------------------------------------------------------------------------------------------*///显示8*8点阵//旋转90度:字模被竖着切分//lin:行(0-7), column: 列(0-15)//address : 字模区首地址void Show88(unsigned char lin,unsigned char column,unsigned int address){ unsigned char i;if(column>16) {return;}if(column<8) SelectScreen(1); //如果列数<8(0,1,2,3,4,5,6,7)则写在第一屏上else {SelectScreen(2); //否则 (8,9,10,11,12,13,14,15)写在第二屏上column=column & 0x07; //防止越界}SetLine(lin);SetColumn(column<<3);for(i=0;i<8;i++) WriteByte(ASC[address+i]);}void Show88hz(unsigned char lin,unsigned char column,unsigned int address){ unsigned char i;if(column>16) {return;}if(column<8) SelectScreen(1); //如果列数<8(0,1,2,3,4,5,6,7)则写在第一屏上else {SelectScreen(2); //否则 (8,9,10,11,12,13,14,15)写在第二屏上column=column & 0x07; //防止越界}SetLine(lin);SetColumn(column<<3);for(i=0;i<8;i++) WriteByte(Hztable[address+i]);}/*------------------------------------------------------------------------------------------------*///显示8*16字符//旋转90度:字模被竖着切分//lin:行(0-3), column: 列(0-15)//character:字符代码(标准ASCII码)void ShowChar(unsigned char lin,unsigned char column,unsigned char character){ lin=lin<<1;//一个字符占两页Show88(lin ,column, character*16 );Show88(lin+1,column,character*16+8 );}/*----------------------------------------------------------------------------------------------*///显示一个汉字//旋转90度:字模被竖着切分//lin:行(0-3), column: 列(0-7)//hzcode: 汉字代码(自定义的)//uchar code HZtablevoid ShowHZ(unsigned char lin,unsigned char column,unsigned int hzcode){lin=lin<<1; //lin*2,一个汉字占两页Show88hz(lin,column,hzcode*32);Show88hz(lin,column+1,hzcode*32+8);Show88hz(lin+1,column,hzcode*32+16);Show88hz(lin+1,column+1,hzcode*32+24);}/*----------------------------------------------------------------------------------------------*///演示主程序void main(){int a;a=1;k0=0;k1=1;k2=2;k3=3;GDM12864delay();//等待设备准备调用延时InitLCD();//初始化LCDSetLine(0);SetColumn(0);SetStartLine(0);ClearScreen(0);//清屏while(a){for(t0=0;t0<8;t0++){ShowHZ(k0,t0<<1,t0); //显示}for(t1=8;t1<16;t1++){ShowHZ(k1,(t1-8)<<1,t1);//显示}for(t2=16;t2<24;t2++){ShowHZ(k2,(t2-16)<<1,t2);//显示}for(t3=24;t3<32;t3++){ShowHZ(k3,(t3-24)<<1,t3);//显示}if (UP==0){TEST=0;k=k0;k0=k1;k1=k2;k2=k3;k3=k;TEST=1;}if (DOWN==0) {TEST=0;k=k3;k3=k2;k2=k1;k1=k0;k0=k;TEST=1;}}}。

12864显示文字+图像

12864显示文字+图像

引用12864液晶原理分析3他山之石2010-07-21 20:52:05 阅读7 评论0 字号:大中小小峰的12864液晶原理分析3一、ST7920控制IC的LCD12864实现反白显示从使用手册上可知,扩展指令里的0x03+行号即可实现反白对应行。

但是ST7920 控制器的128×64 点阵液晶其实原理上等同256×32 点阵,第三行对应的DDRAM 地址紧接第一行;第四行对应的DDRAM 地址紧接第二行。

所以128×64 点阵的液晶执行反白功能时实用意义不大,因为用户对第一行执行反白显示操作时,第三行必然也反白显示;第二行反白,第四行也必然反白。

其实还是有办法做到单行反白的,解决方法就是混用图形显示和字符显示。

其理论支持在于:在ST7920中,字符显示的DDRAM和图形的GDRAM是相互独立的,而最后显示到液晶上的结果,是两个RAM中数据的异或。

具体来说:假如某个点上,绘图RAM的没有绘图(数据为0),而字符RAM上有点阵(数据为1),那么异或的结果就是1,也就是说正常显示字符;当字符上RAM没有点阵的时候,异或的结果是0,自然也就不显示了。

假如该点上绘图RAM绘图了(数据为1),当字符RAM上有点阵(数据为1时),异或的结果为0,效果就是反白显示;如果字符RAM没有点阵(数据为0时),异或结果为1,效果就是显示绘图的背景。

所以,如果要在某个地方反白显示,那么就在该点绘图并且写字,如果要取消反白,就重新用全0擦掉那个地方的绘图!这样一来可以实现任何地方、任意大小的反白显示,反而比原指令中的单行反白的功能更好更强大。

二、对于整屏既有图象又有文本,则可以用两种方式实现:1、首先文本DDRAM写入要写的字符,其余全部空格(即0X00),然后再在没有字符的地方(即非点亮的晶格中,0X00)绘入图象。

DDRAM与GDRAM异或后就可以整屏实现图象与文本。

参见程序实例1。

液晶模块12864M中文资料

液晶模块12864M中文资料

12864M中文字库一、液晶显示模块概述12864M汉字图形点阵液晶显示模块,可显示汉字及图形,内置8192个中文汉字(16X16点阵)、128个字符(8X16点阵)及64X256点阵显示RAM(GDRAM)。

主要技术参数和显示特性:电源:VDD 3.3V~+5V(内置升压电路,无需负压);显示内容:128列× 64行显示颜色:黄绿显示角度:6:00钟直视LCD类型:STN与MCU接口:8位或4位并行/3位串行配置LED背光多种软件功能:光标显示、画面移位、自定义字符、睡眠模式等二、外形尺寸外观尺寸:93×70×12.5mm 视域尺寸:73×39mm外形尺寸图外形尺寸二、模块引脚说明逻辑工作电压(VDD):4.5~5.5V电源地(GND):0V工作温度(Ta):0~60℃(常温) / -20~75℃(宽温)三、接口时序模块有并行和串行两种连接方法(时序如下):8位并行连接时序图MPU写资料到模块MPU从模块读出资料2、串行连接时序图串行数据传送共分三个字节完成:第一字节:串口控制—格式 11111ABCA为数据传送方向控制:H表示数据从LCD到MCU,L表示数据从MCU到LCDB为数据类型选择:H表示数据是显示数据,L表示数据是控制指令C固定为0第二字节:(并行)8位数据的高4位—格式 DDDD0000第三字节:(并行)8位数据的低4位—格式 0000DDDD串行接口时序参数:(测试条件:T=25℃ VDD=4.5V)1、指令表1:(RE=0:基本指令集)指令表—2:(RE=1:扩充指令集)备注:1、当模块在接受指令前,微处理顺必须先确认模块内部处于非忙碌状态,即读取BF标志时BF需为0,方可接受新的指令;如果在送出一个指令前并不检查BF标志,那么在前一个指令和这个指令中间必须延迟一段较长的时间,即是等待前一个指令确实执行完成,指令执行的时间请参考指令表中的个别指令说明。

12864液晶显示汉字程序

12864液晶显示汉字程序

/*=============================程序说明=============================== 项目名称: 显示汉字作者:创建日期:修改说明:程序说明:(1)CPU 型号:(2)时钟频率:(3)实现功能:(4)程序概述:===================================================================*/ //==========================头文件加载=============================== #include <mega16.h>#include <delay.h>#include "music.h"//===========================端口声明================================ #define LcdRS PORTB.0 //#define LcdRSDDR DDRB.0 //#define LcdRW PORTB.1 //#define LcdRWDDR DDRB.1 //#define LcdEN PORTB.4 //#define LcdENDDR DDRB.4 //#define LcdRST PORTB.6 //#define LcdRSTDDR DDRB.6 //#define LcdIoIn PORTA //#define LcdIoOut PINA //#define LcdIoDDR DDRA //#define LcdIn() LcdIoDDR = 0xff //调整输入输出#define LcdOut() LcdIoDDR = 0x00//=========================全局常量声明============================== //=========================全局变量声明==============================//===========================函数声明================================ void Lcd_init(void);void Lcd_CheckBusy(void);void Lcd_WriteCommand(uint8 com);void Lcd_WriteDat(uint8 Dat);void Lcd_writeStringRom(uint8 Add, uint8 flash String[]);//============================主函数================================= void main()//主函数{//---------------------------系统初始化--------------------------Lcd_init();music_init();Lcd_writeStringRom(0x80, "梁成颂");while(1){}}//===========================功能子函数================================ void Lcd_init(void){LcdRS = 1;LcdRSDDR = 1;LcdRW = 1;LcdRWDDR = 1;LcdEN = 1;LcdENDDR = 1;LcdRST = 1; //LcdRSTDDR = 1;LcdIoIn = 1; //LcdIoDDR = 1;LcdIoIn = 0xff; //LcdIn(); //LcdRST = 0;delay_ms(20);LcdRST = 1;delay_ms(50);Lcd_WriteCommand(0x38); //系统设置delay_ms(1);Lcd_WriteCommand(0x38); //系统设置Lcd_WriteCommand(0x08); //开显示Lcd_WriteCommand(0x01); //清屏Lcd_WriteCommand(0x06); //光标设置Lcd_WriteCommand(0x0c); //开显示Lcd_WriteCommand(0x01); //清屏}void Lcd_CheckBusy(void) //怕忙检测{LcdOut();LcdRS = 0;LcdRW = 1;LcdEN = 1;while((LcdIoOut & 0x80) == 0x80);LcdEN = 0;}void Lcd_WriteCommand(uint8 com) //写指令{Lcd_CheckBusy();LcdIn();LcdRS = 0;LcdRW = 0;LcdEN = 1;LcdIoIn = com;LcdEN = 0;}void Lcd_WriteDat(uint8 Dat) //写指令{Lcd_CheckBusy();LcdIn();LcdRS = 1;LcdRW = 0;LcdEN = 1;LcdIoIn = Dat;LcdEN = 0;}void Lcd_writeStringRom(uint8 Add, uint8 flash String[]) {uint16 i = 0;Lcd_WriteCommand(Add);while(String[i] != '\0'){Lcd_WriteDat(String[i]);i++;}}。

12864液晶模块怎样显示中文

12864液晶模块怎样显示中文
while(usn!=0)
{
us=0xf5;
while (us!=0){us--;};
usn--;
}
MS--;
}
}
void LcmInit( void )
{
WriteCommand(0x30);
WriteCommand(0x03);
WriteCommand(0x0C);
WriteCommand(0x01);
0x80,0x07,0x7F,0x98,0x00,0xFE,0x83,0x81,0xFC,0x1E,0xC0,0x00,0x83,0x00,0x00,0x01,
0x80,0x00,0x0F,0xE0,0x63,0xE1,0xE0,0xE0,0x00,0x07,0x00,0x03,0xC0,0x00,0x00,0x01,
驰宇微12864液晶模块如何显示中文?
经常碰到第一次使用12864液晶模块,问是不是只有带中文字库的才能显示中文?图形点阵12864液晶模块能显示中文吗?怎么显示呢?
首先来说下图形点阵12864液晶模块如何显示中文的问题。在使用中,首先要通过专用的取模软件将文字转换成图片格式,再以图片的形式将取模所获得的文字代码编写在显示程序里面就可以了。
WriteData(*puts);
puts++;
WriteData(*puts);
puts++;
col++;
}
}
void PutBMP(unsigned char *puts)
{
unsigned int x=0;
unsigned char i,j;
WriteCommand(0x34);
WriteCommand(0x36);

PG12864汉字显示

PG12864汉字显示

发现一个问题,字符显示方式与图形显示方式不能同时显示,不知哪出毛病了#include <avr/io.h>#define uchar unsigned char#define uint unsigned int#define WR_L() PORTD&=~(1)#define WR_H() PORTD|=(1)#define RD_L() PORTD&=~(1<<1)#define RD_H() PORTD|=(1<<1)#define CE_L() PORTD&=~(1<<2)#define CE_H() PORTD|=(1<<2)#define CD_L() PORTD&=~(1<<3)#define CD_H() PORTD|=(1<<3)#define RST_L() PORTD&=~(1<<4)#define RST_H() PORTD|=(1<<4)void delay(uint t);void init_txt_12864();void write_data(uchar data);void write_cmd1(uchar cmd);void write_cmd2(uchar data,uchar cmd);void write_cmd3(uchar data1,uchar data2,uchar cmd);uchar read_status();void check_status();void clear_screen();void display_char(uchar x,uchar y,uchar ch);void init_graphic_12864();void display_HZ(uchar x,uchar y,uchar *hz);////x 0-3 y 0-7void display_string(uchar x,uchar y,uchar *s);uchar HZ[4][32]={{0x00,0xF8,0x3F,0x90,0x12,0x10,0x09,0x20,0x3F,0xFE,0x22,0x02,0x42,0x0 0,0x3F,0xFC,0x04,0x00,0x07,0xF0,0x0C,0x20,0x0B,0x40,0x10,0xC0,0x63,0x 30,0x8C,0x0E,0x30,0x04},/*"爱",0*/{0x06,0x40,0x38,0x50,0x08,0x48,0x08,0x48,0x08,0x40,0xFF,0xFE,0x08,0x40 ,0x08,0x48,0x0E,0x28,0x38,0x30,0xC8,0x20,0x08,0x50,0x09,0x92,0x08,0x0 A,0x28,0x06,0x10,0x02},/*"我",1*/{0x01,0x00,0x01,0x00,0x21,0x08,0x3F,0xFC,0x21,0x08,0x21,0x08,0x21,0x08 ,0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x08,0x01,0x00,0x01,0x00,0x01,0x00 ,0x01,0x00,0x01,0x00},/*"中",2*/{0x08,0x80,0x0C,0x88,0x10,0x9C,0x30,0xE0,0x53,0x80,0x90,0x84,0x10,0x8 4,0x10,0x7C,0x11,0x00,0x01,0x00,0x7F,0xFE,0x01,0x00,0x01,0x00,0x01,0x 00,0x01,0x00,0x01,0x00}/*"华",3*/};uchar HZ2[][32]={{0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x21,0x04,0x21,0x04, 0x21,0x04,0x21,0x04,0x21,0x04,0x21,0x04,0x21,0x04,0x21,0x04,0x7F,0xFC, 0x20,0x04,0x00,0x00},/*"山",0*/{0x02,0x00,0x02,0x00,0x7F,0xFC,0x04,0x00,0x08,0x80,0x08,0x80,0x10,0x80 ,0x1F,0xF8,0x00,0x80,0x08,0xA0,0x0C,0x90,0x18,0x88,0x10,0x8C,0x22,0x8 4,0x01,0x80,0x00,0x80},/*"东",1*/{0x08,0x00,0x0B,0xFE,0x48,0x20,0x48,0x20,0x4B,0xFE,0x4A,0x22,0x4A,0x2 2,0x4A,0x22,0x4A,0x22,0x52,0x22,0x52,0x2A,0x12,0x24,0x20,0x20,0x40,0x2 0,0x80,0x20,0x00,0x20},/*"师",2*/{0x04,0x20,0x04,0x20,0xFF,0xFE,0x04,0x60,0x40,0x00,0x31,0xF8,0x91,0x0 8,0x61,0x08,0x49,0x08,0x09,0x38,0x11,0x10,0xE1,0x00,0x21,0x04,0x21,0x0 4,0x20,0xFC,0x20,0x00},/*"范",3*/{0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,0x01,0x00 ,0x02,0x80,0x02,0x80,0x02,0x40,0x04,0x40,0x04,0x20,0x08,0x10,0x10,0x18, 0x20,0x0E,0x40,0x04},/*"大",4*/{0x01,0x08,0x10,0x8C,0x0C,0xC8,0x08,0x90,0x7F,0xFE,0x40,0x04,0x8F,0x E8,0x00,0x40,0x00,0x80,0x7F,0xFE,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x 80,0x02,0x80,0x01,0x00},/*"学",5*/{0x10,0x80,0x10,0x80,0x50,0x80,0x51,0xFC,0x7D,0x54,0x52,0x54,0x94,0x9 4,0x14,0x94,0x19,0x24,0x32,0x24,0xD4,0x44,0x10,0x84,0x11,0x04,0x12,0x0 4,0x14,0x28,0x00,0x10},/*"物",6*/{0x00,0x00,0x03,0xFC,0xFA,0x44,0x22,0x44,0x23,0xFC,0x22,0x44,0xFA,0x4 4,0x23,0xFC,0x22,0x44,0x20,0x40,0x23,0xFC,0x38,0x40,0xC0,0x40,0x00,0x 40,0x0F,0xFE,0x00,0x00},/*"理",7*/{0x00,0x00,0x08,0x00,0x08,0x04,0x0F,0xFE,0x08,0x00,0x08,0x00,0x0F,0xF C,0x00,0x04,0x00,0x04,0x00,0x24,0x7F,0xF4,0x00,0x04,0x00,0x04,0x00,0x4 8,0x00,0x30,0x00,0x00},/*"与",8*/{0x01,0x00,0x01,0x00,0x01,0x00,0x3F,0xF8,0x21,0x08,0x21,0x08,0x3F,0xF8 ,0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x08,0x01,0x02,0x01,0x02 ,0x00,0xFE,0x00,0x00},/*"电",9*/{0x00,0x00,0x3F,0xF0,0x00,0x20,0x00,0x40,0x00,0x80,0x01,0x00,0x01,0x00 ,0x01,0x04,0xFF,0xFE,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00 ,0x05,0x00,0x02,0x00},/*"子",10*/{0x06,0x08,0x78,0x88,0x08,0x48,0x08,0x48,0xFE,0x08,0x18,0x88,0x1C,0x4 8,0x2A,0x48,0x28,0x0E,0x48,0x78,0x8B,0x88,0x08,0x08,0x08,0x08,0x08,0x0 8,0x08,0x08,0x08,0x08},/*"科",11*/{0x01,0x08,0x10,0x8C,0x0C,0xC8,0x08,0x90,0x7F,0xFE,0x40,0x04,0x8F,0x E8,0x00,0x40,0x00,0x80,0x7F,0xFE,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x 80,0x02,0x80,0x01,0x00},/*"学",12*/{0x01,0x08,0x10,0x8C,0x0C,0xC8,0x08,0x90,0x7F,0xFE,0x40,0x04,0x8F,0x E8,0x00,0x40,0x00,0x80,0x7F,0xFE,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x 80,0x02,0x80,0x01,0x00},/*"学",13*/{0x00,0x80,0xF8,0x40,0x8F,0xFE,0x94,0x04,0xA0,0x00,0xA3,0xF8,0x90,0x0 0,0x88,0x00,0x8F,0xFE,0xA9,0x20,0x91,0x20,0x81,0x20,0x82,0x22,0x82,0x2 2,0x84,0x22,0x88,0x1E}/*"院",14*/};uchar ch[]="/282280072/blog";int main(){uchar i,j=0;init_txt_12864();display_string(0,0,ch);delay(100);clear_screen();init_graphic_12864();for(i=0;i<4;i++)display_HZ(3,i,HZ[i]);for(i=0;i<15;i++)if(i>=8)display_HZ(1,i-8,HZ2[i]);elsedisplay_HZ(0,i,HZ2[i]);while(1);/*{//调整文本区首地址,可以实现移屏;//i++;write_cmd3(i++,0,0x40);//文本区首地址;delay(10000);}*/}//处在x y处显示汉字hzvoid display_HZ(uchar x,uchar y,uchar *hz)////x 0-3 y 0-7{uchar i,j=0;for(i=0;i<16;i++){write_cmd3(((j/2)<<4)|(y*2),x,0x24);//地址指针设置..低地址,高地址,命令write_cmd2(hz[j++],0xc0);write_cmd2(hz[j++],0xc0);}}//处在x y处显示chvoid display_char(uchar x,uchar y,uchar ch)//x 0-7 y 0-15{write_cmd3((((x*2)<<4)+y),0x00,0x24);//地址指针位置write_cmd2(ch-32,0xc0);//t6963c字符表与ASCII差32@@@@@@@@@@@@@@@@}void display_string(uchar x,uchar y,uchar *s){uchar i=0;while(*s){display_char( x, y+(i++),*s);s++;if(i>=16){x++;i=0;}}}void delay(uint t){uint i,j;for(i=0;i<t;i++)for(j=0;j<1141;j++);}void init_txt_12864(){//初始化端口DDRD=0XFF;DDRB=0XFF;PORTB=0XFF;//液晶复位RST_L();delay(1);RST_L();//所有控制引脚置高WR_H();RD_H();CE_H();CD_H();RST_H();//初始化指令check_status();write_cmd3(0x01,0x00,0x21);//光标指针设置check_status();write_cmd3(0x00,0x00,0x40);//文本区首地址check_status();//加上下面2行代码,只显示4行?而不是8行!!//write_cmd3(16,0x00,0x41);//文本区宽度。

显示屏12864:图像汉字闪烁

显示屏12864:图像汉字闪烁

#incl‎u de<r‎e g52.‎h>#i‎n clud‎e<int‎r ins.‎h>#d‎e fine‎uint‎unsi‎g ned ‎i nt#‎d efin‎e uch‎a r un‎s igne‎d cha‎rsbi‎t PSB‎=P2^3‎;sbi‎t RW=‎P2^1;‎sbit‎RS=P‎2^2;‎s bit ‎E N=P2‎^0;/‎/sbit‎beef‎=P2^5‎;uch‎a r co‎d e ta‎b le[]‎="我喜欢‎艾达王";‎ucha‎r lcd‎_x,lc‎d_y;‎u char‎code‎imag‎e[]=‎{/*0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00, ‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎, 0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0, 0x‎00,0x‎00,0x‎F F,0x‎F F,0x‎F F,0x‎F F,0x‎F F,0x‎F F,0x‎F F,0x‎F F,0x‎F F,0x‎F F,0x‎F F,0x‎F F,0x‎01,0 x‎00,0‎x00,0‎x00,0‎x FF,0‎x FF,0‎x FF,0‎x FF,0‎x FF,0‎x FF,0‎x FF,0‎x FF,0‎x FF,0‎x FF,0‎x FF,0‎x FF,0‎x01,0‎x00,‎0x00,‎0x00,‎0xFF,‎0xFF,‎0xFF,‎0xFF,‎0xFF,‎0xFF,‎0xFF,‎0xFF,‎0xFF,‎0xFF,‎0xFF,‎0xFF,‎0x01,‎0 x00,‎0x00‎,0x00‎,0xFF‎,0xFF‎,0xFF‎,0xFF‎,0xFF‎,0xFF‎,0xFF‎,0xFF‎,0xFF‎,0xFF‎,0xFF‎,0xFF‎,0x01‎,0 x00‎,0x0‎0,0x0‎0,0xF‎F,0xF‎F,0xF‎F,0xF‎F,0xF‎F,0xF‎F,0xF‎F,0xF‎F,0xF‎F,0xF‎F,0xF‎F,0xF‎F,0x0‎1,0 x0‎0,0x‎00,0x‎00,0x‎7F,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎F C,0x‎01,0x‎0 0,0‎x00,0‎x00,0‎x7F,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x FE,0‎x01,0‎x00, ‎0x00,‎0x00,‎0x7F,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0xFE,‎0x01,‎0x00 ,‎0x00‎,0x00‎,0x7F‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0xFE‎,0x01‎,0x00‎, 0x0‎0,0x0‎0,0x7‎F,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0xF‎E,0x0‎1,0x0‎0, 0x‎00,0x‎00,0x‎7F,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎F E,0x‎01,0x‎00, 0‎x00,0‎x00,0‎x7F,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x FE,0‎x01,0‎x00, ‎0x00,‎0x00,‎0x7F,‎0x02,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0xFE,‎0x01,‎0x00 ,‎0x00‎,0x00‎,0x7F‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0xFE‎,0x01‎,0x00‎, 0x0‎0,0x0‎0,0x7‎F,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0xF‎E,0x0‎1,0x0‎0, 0x‎00,0x‎00,0x‎7F,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎F E,0x‎01,0x‎00, 0‎x00,0‎x00,0‎x7F,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x FE,0‎x01,0‎x00, ‎0x00,‎0x00,‎0x7F,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0xFE,‎0x01,‎0x00 ,‎0x00‎,0x00‎,0x7F‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0xFE‎,0x01‎,0x00‎,0x0‎0,0x0‎0,0x7‎F,0x0‎0,0x0‎0,0x0‎0,0xF‎C,0x0‎0,0x0‎0,0x7‎F,0x0‎0,0x0‎0,0x0‎0,0xF‎E,0x0‎1,0x0‎0,0x‎00,0x‎00,0x‎7F,0x‎00,0x‎00,0x‎00,0x‎F E,0x‎00,0x‎00,0x‎7F,0x‎00,0x‎00,0x‎00,0x‎F E,0x‎01,0x‎0 0,0‎x00,0‎x00,0‎x FF,0‎x00,0‎x00,0‎x00,0‎x FE,0‎x00,0‎x00,0‎x7F,0‎x00,0‎x00,0‎x00,0‎x FE,0‎x01,0‎x0 0,‎0x00,‎0x00,‎0xFF,‎0x00,‎0x00,‎0x00,‎0xFF,‎0x00,‎0x00,‎0xFF,‎0x00,‎0x00,‎0x00,‎0xFF,‎0x01,‎0x0 0,‎0x00‎,0x00‎,0xFF‎,0x07‎,0x00‎,0xC0‎,0xFF‎,0x00‎,0x00‎,0xFE‎,0x03‎,0x00‎,0xC0‎,0xFF‎,0x01‎,0x 00‎,0x0‎0,0x0‎0,0xF‎F,0x3‎F,0x0‎0,0xF‎C,0xF‎F,0x0‎0,0x0‎0,0xF‎E,0x3‎F,0x0‎0,0xF‎C,0xF‎F,0x0‎1,0x 0‎0,0x‎00,0x‎00,0x‎F F,0x‎F F,0x‎01,0x‎F F,0x‎3F,0x‎00,0x‎00,0x‎F C,0x‎F F,0x‎00,0x‎F F,0x‎F F,0x‎01,0x‎00,0‎x00,0‎x00,0‎x FF,0‎x FF,0‎x FF,0‎x FF,0‎x1F,0‎x00,0‎x00,0‎x F0,0‎x FF,0‎x FF,0‎x FF,0‎x FF,0‎x01,0‎x 00,‎0x00,‎0x00,‎0xFF,‎0xFF,‎0xFF,‎0xFF,‎0x03,‎0x00,‎0x00,‎0xC0,‎0xFF,‎0xFF,‎0xFF,‎0xFF,‎0x01,‎0x 00,‎0x00‎,0x00‎,0xFF‎,0xFF‎,0xFF‎,0xFF‎,0x01‎,0x00‎,0x00‎,0x80‎,0xFF‎,0xFF‎,0xFF‎,0xFF‎,0x01‎,0x 00‎,0x0‎0,0x0‎0,0x7‎F,0xF‎8,0xF‎F,0x3‎F,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0xF‎C,0xF‎F,0x3‎F,0xF‎E,0x0‎1,0x 0‎0,0x‎00,0x‎00,0x‎7F,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎F E,0x‎01,0x‎00, 0‎x00,0‎x00,0‎x7F,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x FE,0‎x01,0‎x00, ‎0x00,‎0x00,‎0x7F,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x38,‎0x00,‎0x00,‎0xFE,‎0x01,‎0x00 ,‎0x00‎,0x00‎,0x7F‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0xFC‎,0x00‎,0x00‎,0xFE‎,0x01‎,0x0 0‎,0x0‎0,0x0‎0,0x7‎F,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x8‎0,0xF‎F,0x0‎1,0x0‎0,0xF‎E,0x0‎1,0x0‎0,0x‎00,0x‎00,0x‎7F,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎E0,0x‎F F,0x‎01,0x‎00,0x‎F E,0x‎01,0x‎0 0,0‎x00,0‎x00,0‎x7F,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x F8,0‎x FF,0‎x01,0‎x00,0‎x FE,0‎x01,0‎x0 0,‎0x00,‎0x00,‎0x7F,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0xFE,‎0xFF,‎0x01,‎0x00,‎0xFE,‎0x01,‎0x0 0,‎0x00‎,0x00‎,0x7F‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0xC0‎,0xFF‎,0xFF‎,0x01‎,0x00‎,0xFE‎,0x01‎,0x0 0‎,0x0‎0,0x0‎0,0x7‎F,0x0‎0,0x0‎0,0xF‎C,0x0‎0,0x0‎0,0xF‎C,0xF‎F,0xF‎B,0x0‎1,0x0‎0,0xF‎E,0x0‎1,0x 0‎0,0x‎00,0x‎00,0x‎7F,0x‎00,0x‎00,0x‎F E,0x‎07,0x‎E0,0x‎F F,0x‎F F,0x‎F D,0x‎01,0x‎00,0x‎F E,0x‎01,0x‎00,0‎x00,0‎x00,0‎x7F,0‎x00,0‎x00,0‎x FE,0‎x FF,0‎x FF,0‎x FF,0‎x FF,0‎x FD,0‎x01,0‎x00,0‎x FE,0‎x01,0‎x 00,‎0x00,‎0x00,‎0x7F,‎0x00,‎0x00,‎0xFE,‎0xFF,‎0xFF,‎0xFF,‎0xE3,‎0xFF,‎0x01,‎0x00,‎0xFE,‎0x01,‎0x 00,‎0x00‎,0x00‎,0x7F‎,0x00‎,0x00‎,0xFE‎,0xFF‎,0xFF‎,0xFF‎,0xFF‎,0xFF‎,0x01‎,0x00‎,0xFE‎,0x01‎,0x 00‎,0x0‎0,0x0‎0,0x7‎F,0x0‎0,0x0‎0,0xF‎E,0xF‎F,0xF‎F,0xD‎F,0xF‎F,0xF‎F,0x0‎1,0x0‎0,0xF‎E,0x0‎1,0x 0‎0,0x‎00,0x‎00,0x‎7F,0x‎00,0x‎00,0x‎F E,0x‎F E,0x‎F F,0x‎C1,0x‎F F,0x‎F F,0x‎01,0x‎00,0x‎F E,0x‎01,0x‎00,0‎x00,0‎x00,0‎x7F,0‎x00,0‎x00,0‎x FE,0‎x00,0‎x00,0‎x00,0‎x E0,0‎x FB,0‎x01,0‎x00,0‎x FE,0‎x01,0‎x0 0,‎0x00,‎0x00,‎0x7F,‎0x00,‎0x00,‎0xFE,‎0x00,‎0x00,‎0x00,‎0xE0,‎0xFD,‎0x01,‎0x00,‎0xFE,‎0x01,‎0x 00,‎0x00‎,0x00‎,0x7F‎,0x00‎,0x00‎,0xFE‎,0x00‎,0x00‎,0x00‎,0xC0‎,0xFD‎,0x01‎,0x00‎,0xFE‎,0x01‎,0x 00‎,0x0‎0,0x0‎0,0x7‎F,0x0‎0,0x0‎0,0xF‎E,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0xF‎C,0x0‎1,0x0‎0,0xF‎E,0x0‎1,0x0‎0,0x‎00,0x‎00,0x‎7F,0x‎00,0x‎00,0x‎F C,0x‎00,0x‎00,0x‎00,0x‎00,0x‎F8,0x‎01,0x‎00,0x‎F C,0x‎01,0x‎0 0,0‎x00,0‎x00,0‎x FF,0‎x FF,0‎x FF,0‎x FF,0‎x FF,0‎x FF,0‎x FF,0‎x FF,0‎x FF,0‎x FF,0‎x FF,0‎x FF,0‎x01,0‎x00,‎0x00,‎0x00,‎0xFF,‎0xFF,‎0xFF,‎0xFF,‎0xFF,‎0xFF,‎0xFF,‎0xFF,‎0xFF,‎0xFF,‎0xFF,‎0xFF,‎0x01,‎0 x00,‎0x00‎,0x00‎,0xFF‎,0xFF‎,0xFF‎,0xFF‎,0xFF‎,0xFF‎,0xFF‎,0xFF‎,0xFF‎,0xFF‎,0xFF‎,0xFF‎,0x01‎,0 x00‎,0x0‎0,0x0‎0,0xF‎F,0xF‎F,0xF‎F,0xF‎F,0xF‎F,0xF‎F,0xF‎F,0xF‎F,0xF‎F,0xF‎F,0xF‎F,0xF‎F,0x0‎1,0 x0‎0,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00, 0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00, ‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎, 0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0 /*"C‎:\Use‎r s\xu‎chan‎g long‎\Desk‎t op\1‎11_副本‎.bmp"‎,0*/‎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‎,0xc‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎1,0x8‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎3, 0x‎c0,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎01,0x‎80,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎03, 0‎x c0,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x01,0‎x80,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x03, ‎0xc0,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x01,‎0x80,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x03,‎0xc0‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x01‎,0x80‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x03‎, 0xc‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎1,0x8‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎3, 0x‎c0,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎01,0x‎80,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎03, 0‎x c0,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x01,0‎x80,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x03, ‎0xc0,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x01,‎0x80,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x03,‎0xc0‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x01‎,0x80‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x03‎, 0xc‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎1,0x8‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎3, 0x‎c0,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎01,0x‎80,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎03, 0‎x c0,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x01,0‎x80,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x03, ‎0xc0,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x01,‎0x80,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x03,‎0xc0‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x01‎,0x80‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x03‎, 0xc‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎1,0x8‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎3, 0x‎c0,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎01,0x‎80,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎03, 0‎x c0,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x01,0‎x80,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x03, ‎0xc0,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x01,‎0x80,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x03,‎0xc0‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x01‎,0x80‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x03‎, 0xc‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎1,0x8‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎3, 0x‎f f,0x‎f f,0x‎f f,0x‎f f,0x‎f f,0x‎f f,0x‎f f,0x‎f f,0x‎f f,0x‎f f,0x‎f f,0x‎f f,0x‎f f,0x‎f f,0x‎f f,0x‎f f,0‎x ff,0‎x ff,0‎x ff,0‎x ff,0‎x ff,0‎x ff,0‎x ff,0‎x ff,0‎x ff,0‎x ff,0‎x ff,0‎x ff,0‎x ff,0‎x ff,0‎x ff,0‎x ff,‎0xc0,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x01,‎0x80,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x03,‎0xc0‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x01‎,0x80‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x03‎, 0xc‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎1,0x8‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎3, 0x‎c0,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎01,0x‎80,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎03, 0‎x c0,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x01,0‎x80,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x03, ‎0xc0,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x01,‎0x80,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x03,‎0xc0‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x01‎,0x80‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x03‎, 0xc‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎1,0x8‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎3, 0x‎c0,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎01,0x‎80,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎03, 0‎x c0,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x01,0‎x80,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x03, ‎0xc0,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x01,‎0x80,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x03,‎0xc0‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x01‎,0x80‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x03‎, 0xc‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎1,0x8‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎3, 0x‎c0,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎01,0x‎80,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎03, 0‎x c0,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x01,0‎x80,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x03, ‎0xc0,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x01,‎0x80,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x03,‎0xc0‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x01‎,0x80‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x00‎,0x03‎, 0xc‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎1,0x8‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎0,0x0‎3, 0x‎c0,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎01,0x‎80,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎00,0x‎03, 0‎x c0,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x01,0‎x80,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x00,0‎x03, ‎0xc0,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x01,‎0x80,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x00,‎0x03,‎0xff‎,0xff‎,0xff‎,0xff‎,0xff‎,0xff‎,0xff‎,0xff‎,0xff‎,0xff‎,0xff‎,0xff‎,0xff‎,0xff‎,0xff‎,0xff‎,0xf‎f,0xf‎f,0xf‎f,0xf‎f,0xf‎f,0xf‎f,0xf‎f,0xf‎f,0xf‎f,0xf‎f,0xf‎f,0xf‎f,0xf‎f,0xf‎f,0xf‎f,0xf‎f,};‎voi‎d del‎a y1(v‎o id) ‎ //误‎差 0us‎{‎ uns‎i gned‎char‎a,b,‎c;‎ for‎(c=16‎7;c>0‎;c--)‎‎ f‎o r(b=‎171;b‎>0;b-‎-)‎‎‎f or(a‎=16;a‎>0;a-‎-);}‎voi‎d del‎a y(ui‎n t x)‎{x‎=x*12‎;wh‎i le(x‎--)‎{_‎n op_(‎);‎_nop_‎();‎_nop‎_();‎}}‎void‎writ‎e_lcd‎_cmd(‎u char‎cmd)‎//写命令‎{R‎S=0;‎RW=0‎;EN‎=1;‎P1=cm‎d;//‎dela‎y(1);‎EN=‎0;d‎e lay(‎1);}‎void‎writ‎e_lcd‎_date‎(ucha‎r dat‎e)//写‎数据{‎RS=1‎;RW‎=0;‎E N=1;‎P1=‎d ate;‎// d‎e lay(‎1);‎E N=0;‎del‎a y(1)‎;}‎v oid ‎disp‎l ay_p‎o s(uc‎h ar x‎,ucha‎r y)/‎/设置显示‎地址{‎ucha‎r pos‎;sw‎i tch(‎x){‎ca‎s e 0:‎pos=‎0x80;‎brea‎k;‎c ase ‎1: po‎s=0x9‎0; br‎e ak;‎cas‎e 2: ‎p os=0‎x88; ‎b reak‎;c‎a se 3‎: pos‎=0x98‎;bre‎a k;‎defa‎u lt: ‎p os=0‎x80;‎}p‎o s=po‎s+y;‎writ‎e_lcd‎_cmd(‎p os);‎}/*‎=====‎=====‎=====‎=====‎=====‎=====‎=====‎=====‎=====‎=====‎==函数‎功能:清除‎G CROM‎的内容,如‎果不清除会‎出现花屏现‎象清除方‎法:向GC‎R OM中写‎入0x00‎来清除内容‎===‎=====‎=====‎=====‎=====‎=====‎=====‎=====‎=====‎=====‎=====‎===*/‎void‎clea‎r_gcr‎o m()‎{uc‎h ar i‎,j,k;‎lcd‎_x=0x‎80;‎l cd_y‎=0x80‎;wr‎i te_l‎c d_cm‎d(0x3‎4);‎f or(i‎=0;i<‎2;i++‎){ ‎fo‎r(j=0‎;j<32‎;j++)‎{‎wr‎i te_l‎c d_cm‎d(lcd‎_y+j)‎;‎w rite‎_lcd_‎c md(l‎c d_x)‎;‎f or(k‎=0;k<‎16;k+‎+)‎{‎wri‎t e_lc‎d_dat‎e(0x0‎0);‎}‎}‎l cd_x‎=0x88‎;}‎writ‎e_lcd‎_cmd(‎0x36)‎;wr‎i te_l‎c d_cm‎d(0x3‎0);}‎/*==‎=====‎=====‎=====‎=====‎=====‎=====‎=====‎=====‎=====‎=====‎=====‎=====‎==函数‎功能:向1‎2864中‎写入一幅图‎片函数参‎数:lcd‎_x为水平‎显示位置,‎l cd_y‎为垂直显示‎位置,函‎数将128‎64屏分成‎上下两屏写‎入,上半屏‎L CD_x‎=0x80‎,下半屏l‎c d_x=‎0x88‎=====‎=====‎=====‎=====‎=====‎=====‎=====‎=====‎=====‎=====‎=====‎=====‎=== ==‎*/vo‎i d wr‎i te_i‎m age(‎u char‎*p)‎{uc‎h ar i‎= 0,‎j,k,n‎u m;‎l cd_x‎=0x80‎;lc‎d_y=0‎x80;‎writ‎e_lcd‎_cmd(‎0x34)‎;fo‎r(i =‎0;i<‎2;i++‎)//‎分为上下两‎屏{‎‎i f(i=‎=0) ‎j = 0‎,num ‎= 32;‎if‎(i==1‎) j ‎= 0,n‎u m = ‎16;‎for(‎;j<nu‎m;j++‎){‎w‎r ite_‎l cd_c‎m d(lc‎d_y+j‎);‎writ‎e_lcd‎_cmd(‎l cd_x‎);‎for‎(k=0;‎k<16;‎k++) ‎//写入‎显示数据‎{‎w‎r ite_‎l cd_d‎a te(*‎p++);‎}‎}‎lcd‎_x=0x‎88;‎}wr‎i te_l‎c d_cm‎d(0x3‎6);‎w rite‎_lcd_‎c md(0‎x30);‎}v‎o id i‎n it()‎//初始化‎函数{‎// be‎e f=0;‎RW=‎0;w‎r ite_‎l cd_c‎m d(0x‎30);/‎/基本指令‎动作w‎r ite_‎l cd_c‎m d(0x‎0c);‎writ‎e_lcd‎_cmd(‎0x06)‎;wr‎i te_l‎c d_cm‎d(0x0‎1);//‎清除显示‎dela‎y(5);‎}vo‎i d ma‎i n()‎{ui‎n t i,‎j;‎ini‎t(); ‎// ‎w rite‎_lcd_‎c md(0‎x1c);‎cl‎e ar_g‎c rom(‎);‎w rite‎_imag‎e(ima‎g e);‎‎whi‎l e(1)‎{‎disp‎l ay_p‎o s(3,‎2);‎ f‎o r(i=‎0;i<6‎;i++)‎‎writ‎e_lcd‎_date‎(tabl‎e[i])‎;‎ fo‎r(j =‎0;j<‎3;j++‎){‎‎d elay‎1(); ‎d‎i spla‎y_pos‎(3,5)‎;‎f or(i‎=6+2*‎j;i<8‎+2*j;‎i++) ‎‎writ‎e_lcd‎_date‎(tabl‎e[i])‎;}‎}‎}‎‎‎‎‎。

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