很好用的12864驱动程序

合集下载

液晶屏12864的FPGA驱动程序

液晶屏12864的FPGA驱动程序

//液晶屏12864驱动芯片型号为ST7920//芯片型号Altera CYCLONE II EP2C8Q208C8//板载时钟50MHzmodule LCD_test(clk,rst,lcd_e,lcd_rs,lcd_rw,data);input clk; //模块输入时钟50MHzinput rst; //复位信号输入output lcd_e; //使能端output lcd_rs; //数据指令选择output lcd_rw; //读写选择output [7:0] data;reg lcd_e; //这样定义是必须的reg lcd_rw;reg lcd_rs;reg [7:0] data;reg [21:0] clkcnt; //分频用计数寄存器reg clkdiv;reg double_div;reg flag; //初始化标志,复位后flag=0,表示未初始化reg [7:0] state;wire bz_clkcnt;parameter idle=8'b0000_0000; //状态0:用于初始化判断parameter setfunction=8'b0010_0000; //用于选择指令集(基本指令集或扩展指令集)parameter switchmode=8'b0000_1000; //显示状态开关parameter setmode=8'b0000_0100; //parameter clear=8'b0000_0001; //清屏,耗时最久的指令parameter setddram=8'b1000_0000; //设定DDRAM地址,即输入字符的位置parameter write1=8'b1111_0000; //输入字符的编码parameter write2=8'b1110_0000; //再次输入assign bz_clkcnt=(clkcnt[21]==1)?1:0;always@(posedge clk or negedge rst) //分频模块,将50MHz的系统时钟降下来beginif(rst==0)clkcnt=0;else if(clkcnt[21]==1)clkcnt=0;elseclkcnt=clkcnt+1;endalways@(posedge bz_clkcnt or negedge rst) //产生占空比50%的时钟信号beginif(rst==0)clkdiv=0;elseclkdiv=~clkdiv;endalways@(posedge clkdiv) //lcd时钟模块,产生用于lcd动作执行的时钟beginif(rst==0)double_div=0;elsedouble_div=~double_div;endalways@(negedge clkdiv) //lcd使能信号产生模块beginif(rst==0)lcd_e=0;elselcd_e=~lcd_e;endalways@(posedge double_div or negedge rst) //LCD初始化模块,状态机beginif(rst==0)beginflag=0;state=0;endelsebegincase(state)idle:beginif(flag==0) //判断初始化标志位flag==0则进入初始化流程beginflag=1; //开始初始化流程并将flag置1(保证只初始化一回)state=setfunction;endelse //若flag==1表示已经进行过初始化,则不进入初始化流程beginlcd_rw=1;endsetfunction:beginlcd_rw=0;lcd_rs=0;data=8'h30;state=switchmode; end switchmode:beginlcd_rw=0;lcd_rs=0;data=8'h0c;state=clear;endclear:beginlcd_rw=0;lcd_rs=0;data=8'h01;state=setmode; endsetmode:beginlcd_rw=0;lcd_rs=0;data=8'h06;state=setddram; endsetddram:beginlcd_rw=0;lcd_rs=0;data=8'h80;state=write1;endwrite1:beginlcd_rw=0;lcd_rs=1;data="a";state=write2;endwrite2:lcd_rw=0;lcd_rs=1;data="b";state=idle;endendcaseendend endmodule。

很好用的12864驱动程序

很好用的12864驱动程序

^///////////////////////////////////////////////////////////#include<>#include<>#define uchar unsigned char#define uint unsigned int//////////单片机与液晶显示的引脚连接/////////)sbit P32=P3^2; //RSTsbit P33=P3^3; //CS2sbit P34=P3^4; //CS1sbit P35=P3^5; //Esbit P36=P3^6; //rs&DIsbit P37=P3^7; // R/W////////延时/////////…void delay(uint v){while(v!=0)v--;}////////复位///////////》void reset(){P32=0;delay(10);P32=1;delay(10);}—////////write code写指令///////void wcode(uchar c,uchar cs1,uchar cs2){P34=cs1;P33=cs2;P37=0;>P36=0;P1=c;P35=0;delay(10);P35=1;delay(10);P35=0;}¥/////////write data写数据///////////////void wdata(uchar c,uchar cs1,uchar cs2){P34=cs1;P33=cs2;P37=1;*P36=0;P1=c;P35=0;delay(10);P35=1;delay(10);P35=0;})////////////set start设置起始行/////////////void set_startline(uchar i)//起始行。

11A5A4A3A2A1A0 共有64行 // 液晶显示器的最底层为第一行{i=0xc0+64-i;//此算法为把最顶层做为第一层wcode(i,1,1);~}////////////set 页值设置,起始列值函数/////////////void set_adr(uchar x,uchar y){x=x+0xb8;//页地址设置。

SPI方式来驱动12864液晶

SPI方式来驱动12864液晶

SPI⽅式来驱动12864液晶这是⽤SPI⽅式来驱动12864液晶的源程序,液晶屏的控制芯⽚为ST7565P经测试SPI的时钟可达到振荡频率的⼆分频。

⽐⽤普通IO⼝模拟串⾏的⽅式快多了。

下⾯贴出源代码,有详细注释。

本程序简单实⽤,可拿去作简单参考。

编译环境:GCC+AVR STUDIO单⽚机:ATMEGA 8515晶振: 3.6864M#include //包含头⽂件#include#define COMMAND 1#define DATA 0///////////////////////////////////////////数据线定义:// SI==========PB5 //// A0==========PC0// CS==========PC2// RES=========PC1// SCL=========PB7///////////////////////////////////////////unsigned char gushi[8][112]PROGMEM={{0x10,0x10,0x92,0x92,0x92,0xF2,0x9E,0x92,0x92,0x92,0x92,0x92,0xFE,0x10,0x10,0x00, //君问归期未有期0x00,0x00,0xF8,0x01,0x06,0xE0,0x22,0x22,0x22,0x22,0xE2,0x02,0x02,0xFE,0x00,0x00,0x00,0xF8,0x00,0x00,0xFF,0x00,0x04,0x84,0x84,0x84,0x84,0x84,0x84,0xFC,0x00,0x00,0x00,0x04,0xFF,0x54,0x54,0x54,0xFF,0x04,0x00,0xFE,0x22,0x22,0x22,0xFE,0x00,0x00,0x40,0x40,0x48,0x48,0x48,0x48,0xC8,0xFF,0x48,0x48,0x48,0x48,0x48,0x40,0x40,0x00,0x00,0x04,0x84,0x44,0xE4,0x34,0x2C,0x27,0x24,0x24,0x24,0xE4,0x04,0x04,0x04,0x00,0x00,0x04,0xFF,0x54,0x54,0x54,0xFF,0x04,0x00,0xFE,0x22,0x22,0x22,0xFE,0x00,0x00},{0x40,0x20,0x10,0x0C,0xFE,0x45,0x44,0x44,0x44,0x44,0x44,0x44,0xFD,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x03,0x02,0x02,0x02,0x02,0x03,0x40,0x80,0x7F,0x00,0x00,0x00,0x87,0x40,0x30,0x0F,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x00,0x00,0x42,0x22,0x1B,0x02,0x02,0x0A,0x33,0x62,0x18,0x07,0x02,0x22,0x42,0x3F,0x00,0x00,0x20,0x20,0x10,0x10,0x08,0x06,0x01,0xFF,0x01,0x02,0x04,0x08,0x18,0x30,0x10,0x00,0x02,0x01,0x00,0x00,0xFF,0x09,0x09,0x09,0x29,0x49,0xC9,0x7F,0x00,0x00,0x00,0x00,0x42,0x22,0x1B,0x02,0x02,0x0A,0x33,0x62,0x18,0x07,0x02,0x22,0x42,0x3F,0x00,0x00},{0x00,0x00,0xFE,0x42,0x42,0x42,0x42,0x7E,0x42,0x42,0x42,0x42,0xFE,0x00,0x00,0x00, //巴⼭夜⾬涨池0x00,0x00,0xE0,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x04,0x04,0x84,0xC4,0x3C,0x14,0x85,0x66,0xBC,0x24,0x24,0x24,0xE4,0x24,0x04,0x00,0x02,0x02,0xF2,0x32,0x52,0x92,0x12,0xFE,0x32,0x52,0x92,0x12,0xF2,0x02,0x02,0x00,0x10,0x61,0x86,0x60,0xF2,0x12,0x12,0x1E,0x80,0xFF,0xA0,0x90,0x88,0x86,0x80,0x00,0x24,0x24,0xE4,0xFC,0xA2,0x22,0x22,0x80,0x70,0x00,0xFF,0x40,0x20,0x18,0x00,0x00,0x10,0x60,0x02,0x8C,0x60,0x80,0xF8,0x40,0x40,0xFE,0x20,0x20,0x10,0xF0,0x00,0x00},{0x00,0x00,0x3F,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x78,0x20,0x00,0x00,0x20,0x7F,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x7F,0x00,0x00,0x02,0x01,0x00,0xFF,0x00,0x82,0x41,0x22,0x14,0x09,0x14,0x23,0x40,0xC0,0x40,0x00,0x00,0x00,0xFF,0x01,0x02,0x04,0x00,0x7F,0x01,0x02,0x44,0x80,0x7F,0x00,0x00,0x00,0x04,0xFC,0x03,0x00,0x01,0x41,0x81,0x7F,0x00,0xFF,0x42,0x0C,0x30,0x60,0x20,0x00,0x02,0x01,0x00,0xFF,0x00,0x83,0x40,0x20,0x18,0x07,0x01,0x06,0x18,0xE0,0x40,0x00,0x08,0x08,0x7C,0x03,0x00,0x00,0x3F,0x40,0x40,0x5F,0x40,0x42,0x44,0x43,0x70,0x00},{0x80,0x40,0xF0,0x1C,0x07,0xE2,0x24,0x24,0x24,0xE4,0x04,0x04,0xFC,0x04,0x04,0x00, //何当共剪西窗烛0x00,0x00,0x40,0x42,0x5C,0x48,0x40,0x40,0x7F,0x40,0x50,0x4E,0x44,0xC0,0x00,0x00,0x00,0x10,0x10,0x10,0x10,0xFE,0x10,0x10,0x10,0x10,0xFE,0x10,0x10,0x10,0x00,0x00,0x00,0x04,0xF4,0x54,0x55,0x56,0x54,0xF4,0x04,0x04,0xE6,0x05,0x04,0xF4,0x04,0x00,0x02,0xF2,0x12,0x12,0x12,0xFE,0x12,0x12,0x12,0xFE,0x12,0x12,0x12,0xF2,0x02,0x00,0x00,0x4C,0x44,0xE4,0x54,0x44,0x64,0xD5,0x46,0x44,0x4C,0x54,0xD4,0x24,0x2C,0x00,0x80,0x60,0x00,0xFF,0x20,0x18,0xF0,0x10,0x10,0xFF,0x12,0x10,0xF0,0x10,0x00,0x00},{0x00,0x00,0x7F,0x00,0x00,0x07,0x02,0x02,0x02,0x07,0x20,0x40,0x3F,0x00,0x00,0x00,0x00,0x00,0x20,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x7F,0x00,0x00,0x02,0x02,0x82,0x42,0x32,0x1F,0x0A,0x02,0x02,0x06,0x0B,0x32,0xE2,0x42,0x02,0x00,0x00,0x08,0x8F,0x89,0x49,0x2B,0x1D,0x0B,0x08,0x08,0x08,0x4A,0x8C,0x7B,0x00,0x00,0x00,0x7F,0x28,0x24,0x22,0x21,0x20,0x20,0x20,0x21,0x22,0x22,0x22,0x7F,0x00,0x00,0x00,0x00,0x00,0xFF,0x44,0x62,0x55,0x49,0x55,0x43,0x41,0x40,0xFF,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x04,0x28,0x63,0x21,0x21,0x3F,0x11,0x15,0x1B,0x30,0x00,0x00},{0x80,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x00,0xFE,0x02,0x02,0x02,0xFE,0x00,0x00, //却话巴⼭夜⾬时0x40,0x41,0x4E,0xC4,0x00,0x20,0x24,0x24,0x24,0x24,0xFC,0x22,0x22,0x22,0x20,0x00,0x00,0x00,0xFE,0x42,0x42,0x42,0x42,0x7E,0x42,0x42,0x42,0x42,0xFE,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x04,0x04,0x84,0xC4,0x3C,0x14,0x85,0x66,0xBC,0x24,0x24,0x24,0xE4,0x24,0x04,0x00,0x02,0x02,0xF2,0x32,0x52,0x92,0x12,0xFE,0x32,0x52,0x92,0x12,0xF2,0x02,0x02,0x00,0x00,0xFC,0x44,0x44,0x44,0xFC,0x10,0x90,0x10,0x10,0x10,0xFF,0x10,0x10,0x10,0x00},{0x00,0x10,0x3C,0x13,0x10,0x08,0x0A,0x1C,0x08,0xFF,0x00,0x08,0x10,0x0F,0x00,0x00,0x00,0x00,0x00,0x7F,0x20,0x10,0x00,0x7E,0x22,0x22,0x23,0x22,0x22,0x7E,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x78,0x20,0x00,0x00,0x20,0x7F,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x7F,0x00,0x00,0x02,0x01,0x00,0xFF,0x00,0x82,0x41,0x22,0x14,0x09,0x14,0x23,0x40,0xC0,0x40,0x00,0x00,0x00,0xFF,0x01,0x02,0x04,0x00,0x7F,0x01,0x02,0x44,0x80,0x7F,0x00,0x00,0x00,0x00,0x07,0x04,0x04,0x04,0x07,0x00,0x00,0x03,0x40,0x80,0x7F,0x00,0x00,0x00,0x00},};//////////////////////////////////发送⼀个字节到ST7565P并等待发送完毕//⼊⼝:要发送的字节//返回值:⽆////////////////////////////////void SPIByte(unsigned char byte){SPDR = byte; //写数据while(!(SPSR & (1<}//////////////////////////////////////////////////将⼀个字节发送的ST7565P的函数//⼊⼝参数:select ,data//select:根据此值确定发送给ST7565P的是数据还是命令//data: 要发送给ST7565的⼀个字节//返回值:⽆////////////////////////////////////////////////void LCD_SPISend(unsigned char select,unsigned char data){PORTC &= ~(1<<2); // CS=0 芯⽚使能信号if(select == COMMAND) //传输的是命令{PORTC &= ~(1<<0); // 根据ST7565P的数据⼿册,传输命令时A0应该是为低电平 SPIByte(data); PORTC |= 1<<0; // A0=1}else{SPIByte(data);}PORTC |= 1<<2; //CS= 恢复不使能}//////////////////////////////////////////////写坐标函数//⼊⼝参数:x y//y: 页⾯地址,此液晶将显⽰区域分为9个页⾯,y的值域0~8 //x: 列地址,值域:0~127//返回值:⽆////////////////////////////////////////////void LCD_XYSet(unsigned char x,unsigned char y){LCD_SPISend(COMMAND,0xB0|y); //y的值为0~8LCD_SPISend(COMMAND,0x10|(x>>4));}///////////////////////////////////////延时函数//⼊⼝:ms 当延时100毫秒时,ms的值为100即可//返回值:⽆/////////////////////////////////////void DelayMs(volatile unsigned int ms){volatile unsigned int i;volatile unsigned int j;for(i=0;i{j=280;while(j--);}}////////////////////////////////////////////////////////初始化SPI及液晶屏的函数//⼊⼝:⽆//返回值:⽆/////////////////////////////////////////////////////void LCD_Init(void){SPCR = 0x5C;SPSR |= 1<//SPI的功能设置解释:使能SPI;采⽤主机模式;SPI的传输模式为模式3;时钟频率为系统时钟的两分频,即 //3.6864/2M DelayMs(100);SPIByte(0xFF); //可发可不发,⽆意义PORTC &= ~(1<<1); //将复位脚拉低DelayMs(5); //延时5ms,等待电源稳定PORTC |= 1<<1; //将复位脚拉⾼DelayMs(5);LCD_SPISend(COMMAND,0xAE); //将液晶屏的显⽰关掉LCD_SPISend(COMMAND,0xA3); //设置偏压⽐LCD_SPISend(COMMAND,0xA0); //设置SEG 输出⽅向LCD_SPISend(COMMAND,0xC8); //设置公共端输出扫描⽅向LCD_SPISend(COMMAND,0x25); //调整(1 + Rb/Ra) ratio 值,调整此值影响很⼤LCD_SPISend(COMMAND,0x81); //开始设置α的命令LCD_SPISend(COMMAND,0x28); //设置α的值,值越⼤对⽐度越强,调整此值影响不太,是微调的DelayMs(5);LCD_SPISend(COMMAND,0x2F); //开启相关电压DelayMs(50);LCD_SPISend(COMMAND,0xF8);LCD_SPISend(COMMAND,0x01); //此两条命令是设置升压⽐的DelayMs(500); //不知此延时可否省去,不过了安全起见,初次调试保留为好。

12864的驱动程序

12864的驱动程序

12864的驱动程序(51汇编)推荐CS2 BIT P1.5CS1 BIT P1.4E BIT P1.2R_W BIT P1.1D_I BIT P1.0RST BIT P1.3COM EQU 20H ; 指令寄存器DAT EQU 21H ; 数据寄存器DENG BIT P1.6WAIT EQU 22H;中断循环次数(软件延时)ORG 0000HAJMP MAINORG 000BHAJMP TIME_ET0ORG 0050HMAIN:NOPMOV WAIT,#00H;清0MOV TMOD,#01H ;方式1,16位定时器MOV TH0,#00HMOV TL0,#00HMOV R5,#0C0H ;设置行命令,选中的行显示在第一行SETB ET0SETB EA ;开定时,但是还没有开T0定时.程序后面才开CLR RSTSETB RST ;给一个低电平脉冲信号来复位LCD; LCALL DELLY; CPL DENG; MOV COM,#3EH ;指令将显示设置开关关闭; LCALL PR1; LCALL DELLY ;延时一段时间MOV COM,#3FH ;指令将显示设置开关打开LCALL PR1LCALL DELLYCLR CS2 ;清屏(清右半边屏幕)SETB CS1LCALL QINGP;清屏子程序LCALL DELLYCLR CS1SETB CS2LCALL QINGP;清屏子程序LCALL DELLY;调延时子程序等待它反应,我们也可以读它的状态来判断.;SJMP $;---------左屏幕----------------;name1:;显示公司名称CLR CS2SETB CS1;选中左半边屏幕LCALL DELLYMOV DPTR,#ADDRJ;江MOV R3,#0B8H ;页地址MOV R4,#40H ;列地址LCALL HZSHOW;LCALL DELLYMOV DPTR,#ADDRS ;苏MOV R3,#0B8H ;页地址MOV R4,#50H ;列地址LCALL HZSHOW;LCALL DELLYMOV DPTR,#ADDRSH ;省MOV R3,#0B8H ;页地址MOV R4,#60H ;列地址LCALL HZSHOW;LCALL DELLYMOV DPTR,#ADDRJI ;激MOV R3,#0B8H ;页地址MOV R4,#70H ;列地址LCALL HZSHOW;显示公司网址; CLR CS2; SETB CS1;选中左半边屏幕;LCALL DELLYMOV DPTR,#ADDW ;WMOV R3,#0BAHMOV R4,#48HLCALL YWSHOW;LCALL DELLYMOV DPTR,#ADDW ;WMOV R3,#0BAHMOV R4,#50HLCALL YWSHOW;LCALL DELLYMOV DPTR,#ADDW ;WMOV R3,#0BAHMOV R4,#58HLCALL YWSHOW;LCALL DELLYMOV DPTR,#ADDD ;.MOV R3,#0BAHMOV R4,#60HLCALL YWSHOW;LCALL DELLYMOV DPTR,#ADDJ ;JMOV R3,#0BAHMOV R4,#68HLCALL YWSHOW;LCALL DELLYMOV DPTR,#ADDS ;SMOV R3,#0BAHMOV R4,#70HLCALL YWSHOW;LCALL DELLYMOV DPTR,#ADDL ;LMOV R3,#0BAHMOV R4,#78HLCALL YWSHOW;LCALL DELLY;显示图象; CLR CS2; SETB CS1;选中左半边屏幕;LCALL DELLYMOV DPTR,#PIC1 ;图象的首地址MOV R3,#0BCH ;第三页MOV R4,#40H ;第0列LCALL PICSHOW ;图象显示子程序MOV DPTR,#PIC2 ;图象的首地址MOV R3,#0BDH ;第四页MOV R4,#40HLCALL PICSHOW;LCALL DELLYMOV DPTR,#PIC3 ;图象的首地址MOV R3,#0BEHMOV R4,#40HLCALL PICSHOWMOV DPTR,#PIC4 ;图象的首地址MOV R3,#0BFHMOV R4,#40HLCALL PICSHOW; LCALL DELLY ;调用延时子程序;-----------右屏幕-------------- ; LCALL DELLYCLR CS1SETB CS2;LCALL DELLYMOV DPTR,#ADDRG;光MOV R3,#0B8H ;页地址 MOV R4,#40H ;列地址 LCALL HZSHOW;LCALL DELLYMOV DPTR,#ADDRY ;研 MOV R3,#0B8H ;页地址 MOV R4,#50H ;列地址 LCALL HZSHOW;LCALL DELLYMOV DPTR,#ADDRJIU ;究 MOV R3,#0B8H ;页地址 MOV R4,#60H ;列地址 LCALL HZSHOW;LCALL DELLYMOV DPTR,#ADDRSUO ;所 MOV R3,#0B8H ;页地址 MOV R4,#70H ;列地址 LCALL HZSHOW;LCALL DELLY;sjmp name1;LCALL DELLYMOV DPTR,#ADDA ;AMOV R3,#0BAHMOV R4,#40HLCALL YWSHOW;LCALL DELLYMOV DPTR,#ADDS ;SMOV R3,#0BAHMOV R4,#48HLCALL YWSHOW;LCALL DELLYMOV DPTR,#ADDE ;EMOV R3,#0BAHMOV R4,#50HLCALL YWSHOW;LCALL DELLYMOV DPTR,#ADDR ;RMOV R3,#0BAHMOV R4,#58HLCALL YWSHOW;LCALL DELLYMOV DPTR,#ADDD ;.MOV R3,#0BAHMOV R4,#60HLCALL YWSHOW;LCALL DELLYMOV DPTR,#ADDCC ;CMOV R3,#0BAHMOV R4,#68HLCALL YWSHOW;LCALL DELLYMOV DPTR,#ADDN ;NMOV R3,#0BAHMOV R4,#70HLCALL YWSHOW;LCALL DELLYSETB TR0 ;开定时器AJMP $ ;等待定时中断;中断子程序TIME_ET0:INC WAITMOV A,#0AH ;中断16次,CJNE A,WAIT,TT2; SJMP MOV_LINE ;相等则跳转,换行;ADD_WAIT:; MOV TH0,#00H; MOV TL0,#00H ;清空定时器; RETI;MOV_LINE:NOPMOV WAIT,#00H;清空软件记数单元CPL DENG ;猜想是用来指示换行的灯,没什么实际意义CLR CS2SETB CS1 ;选中左屏MOV COM,R5 ;R5当前的内容 #0C0H,该命令是用来设置显示起始行.所设置的行将在第一行显示,估计用来动态显示的.LCALL PR1 ;1100 0000 后六位对应0-63行,当前是将第一行显示CPL CS1CPL CS2 ;切换到右屏显示MOV COM,R5LCALL PR1CJNE R5,#0FFH,TT;MOV R5,#0C0H;重新开始显示下一个轮回的第一行AJMP TT2TT:INC R5;显示下面一行内容TT2:MOV TH0,#00HMOV TL0,#00H;清空定时器RETIQINGP:MOV R3,#0B8HMOV COM,R3 ;设置页地址为0LCALL PR1MOV COM,#40H;设置列地址0LCALL PR1MOV R1,#00HMOV R2,#00HLOOP_CLR:MOV DAT,#00H;输入数据为0则为清掉屏幕LCALL PR2INC R1CJNE R1,#40H,LOOP_CLR;看看是否到了64列了,如果没有满则继续刷新列MOV R1,#00HINC R2 ;用来控制页数的INC R3 ;下一页,设置地址为下一页MOV COM,R3MOV COM,#40H;重新设置列地址0LCALL PR1CJNE R2,#08H,LOOP_CLRRET;16*16汉字显示的子程序HZSHOW:MOV COM,R3 ;R3为页地址LCALL PR1MOV COM,R4 ;R4为列地址LCALL PR1MOV R2,#20H ;32MOV R1,#00H ;R1用来取字码的LOOP:CJNE R2,#10H,LOOP1;如果不相等则跳转,刚刚开始不相等的,如果相等了则换到下一页 INC R3 ;下一页MOV COM,R3LCALL PR1MOV COM,R4 ;R4为列地址LCALL PR1LOOP1:MOV A,R1MOVC A,@A+DPTRMOV DAT,A ;传送字符编码LCALL PR2INC R1DJNZ R2,LOOPRET;10*16英文显示的子程序YWSHOW:MOV COM,R3LCALL PR1MOV COM,R4LCALL PR1MOV R2,#10HMOV R1,#00HLOOP2:CJNE R2,#08H,LOOP22INC R3MOV COM,R3MOV COM,R4LCALL PR1LOOP22:MOV A,R1MOVC A,@A+DPTRMOV DAT,ALCALL PR2INC R1DJNZ R2,LOOP2RET;32*32图片1HANG显示的子程序PICSHOW:MOV COM,R3;页地址LCALL PR1MOV COM,R4;列地址LCALL PR1MOV R2,#20H;32*32的图片MOV R1,#00HLOOP3:MOV A,R1MOVC A,@A+DPTRMOV DAT,ALCALL PR2INC R1DJNZ R2,LOOP3RET;延时DELLY:MOV R7,#0A8HMS2:MOV R6,#0FFHMS1:DJNZ R6,MS1DJNZ R7,MS2RET;读BF和AC值PR0:PUSH ACCMOV P0,#0FFHSETB ESETB R_WMOV COM,P0CLR EPOP ACCRET;写指令子程序PR1:PUSH ACCSETB ECLR D_ICLR R_WMOV P0,COMCLR EPOP ACCRET;写数据子程序PR2:PUSH ACCSETB ESETB D_ICLR R_WMOV P0,DATCLR EPOP ACCRET; 江(0) 苏(1) 省(2) 激(3) 光(4) 研(5) 究(6) 所(7)ADDRJ:;-- 文字: 江 --;-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --DB 10H,60H,01H,0C6H,30H,00H,04H,04H,04H,0FCH,04H,04H,04H,04H,00H,00H;DB 04H,04H,7EH,01H,20H,20H,20H,20H,20H,3FH,20H,20H,20H,20H,20H,00H;"江",0 ADDRS:;-- 文字: 苏 --;-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --DB 04H,04H,44H,44H,44H,5FH,44H,0F4H,44H,5FH,44H,0C4H,04H,04H,04H,00H;DB 00H,40H,4CH,27H,10H,0CH,07H,01H,20H,40H,40H,3FH,00H,02H,0CH,00H;"苏",1 ADDRSH:;-- 文字: 省 --;-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --DB 00H,10H,90H,88H,86H,0C0H,0C0H,0BFH,0A0H,90H,90H,8AH,84H,18H,00H,00H;DB 01H,01H,00H,00H,0FFH,4AH,4AH,4AH,4AH,4AH,4AH,4AH,0FFH,00H,00H,00H;"省",2 ADDRJI:;-- 文字: 激 --;-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --DB 10H,21H,86H,60H,7CH,56H,0D5H,54H,7CH,20H,0F8H,17H,90H,70H,10H,00H;DB 04H,7CH,43H,21H,19H,07H,45H,85H,7DH,20H,13H,0CH,33H,60H,20H,00H;"激",3 ADDRG:;-- 文字: 光 --;-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --DB 00H,40H,42H,44H,5CH,0C8H,40H,7FH,40H,0C0H,50H,4EH,44H,60H,40H,00H;DB 00H,80H,40H,20H,18H,07H,00H,00H,00H,3FH,40H,40H,40H,40H,78H,00H;"光",4ADDRY:;-- 文字: 研 --;-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --DB 02H,0C2H,0F2H,4EH,0C2H,02H,40H,42H,0FEH,42H,42H,42H,0FEH,42H,42H,00H;DB 01H,00H,3FH,10H,9FH,40H,20H,18H,07H,00H,00H,00H,0FFH,00H,00H,00H;"研",5 ADDRJIU:;-- 文字: 究 --;-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --DB 00H,4CH,24H,94H,84H,84H,0F5H,86H,84H,84H,14H,24H,44H,0CH,04H,00H;DB 00H,00H,40H,20H,10H,0CH,03H,00H,00H,3FH,40H,40H,40H,40H,78H,00H;"究",6ADDRSUO:;-- 文字: 所 --;-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --DB 00H,0FEH,12H,12H,11H,0F1H,01H,00H,0FEH,22H,22H,21H,0E1H,21H,21H,00H;DB 40H,3FH,01H,01H,81H,41H,30H,0CH,03H,00H,00H,00H,0FFH,00H,00H,00H;"所",7;公司网址:w(0) w(1) w(2) .(3) j(4) s(5) l(6) a(7) s(8) e(9) r(10) .(11) c(12) n(13) ADDW:;-- 文字: w --DB 80H,80H,00H,80H,00H,80H,80H,80H,0FH,30H,0CH,03H,0CH,30H,0FH,00H;"w",0ADDD:;-- 文字: . --DB 00H,00H,00H,00H,00H,00H,00H,00H,00H,30H,30H,00H,00H,00H,00H,00H;".",3ADDJ:;-- 文字: J --DB 00H,00H,00H,80H,98H,98H,00H,00H,00H,0C0H,80H,80H,80H,7FH,00H,00H;"j",4ADDS:;-- 文字: S --DB 00H,00H,80H,80H,80H,80H,80H,00H,00H,33H,24H,24H,24H,24H,19H,00H;"s",5ADDL:;-- 文字: L --DB 00H,08H,08H,0F8H,00H,00H,00H,00H,00H,20H,20H,3FH,20H,20H,00H,00H;"l",6 ADDA:;-- 文字: A --DB 00H,00H,80H,80H,80H,80H,00H,00H,00H,19H,24H,22H,22H,22H,3FH,20H;"a",7 ADDE:;-- 文字: E --DB 00H,00H,80H,80H,80H,80H,00H,00H,00H,1FH,22H,22H,22H,22H,13H,00H;"e",9 ADDR:;-- 文字: R --DB 80H,80H,80H,00H,80H,80H,80H,00H,20H,20H,3FH,21H,20H,00H,01H,00H;"r",10 ADDCC:;-- 文字: C --DB 00H,00H,00H,80H,80H,80H,00H,00H,00H,0EH,11H,20H,20H,20H,11H,00H;"c",12 ADDN:;-- 文字: N --DB 80H,80H,00H,80H,80H,80H,00H,00H,20H,3FH,21H,00H,00H,20H,3FH,20H;"n",13PIC1:;-- 调入了一幅图像;-- 宽度x高度=32x32 --DB 00H,7FH,09H,0FH,00H,7FH,40H,40H,00H,7FH,41H,41H,00H,00H,00H,00H;DB 00H,00H,00H,00H,7FH,41H,41H,41H,00H,4FH,4AH,4AH,7AH,00H,7FH,00H;PIC2:DB 00H,0FEH,82H,7EH,00H,0C4H,8AH,72H,00H,0FEH,12H,1EH,00H,00H,00H,00H; DB 00H,00H,0FCH,22H,0FCH,00H,0FEH,32H,5EH,80H,0FEH,04H,08H,04H,0FEH,00H; PIC3:DB 00H,00H,0FCH,1CH,0F4H,9CH,80H,80H,80H,00H,00H,00H,20H,0F0H,0B8H,0F8H; DB 0BCH,0F0H,20H,00H,00H,0E0H,0E0H,0E0H,00H,80H,9CH,0F4H,9CH,80H,00H,00H; PIC4:DB 00H,00H,7FH,04H,07H,06H,7EH,7EH,40H,00H,00H,00H,00H,33H,32H,7BH;DB 3AH,3BH,78H,38H,00H,00H,00H,01H,0F1H,11H,12H,0FFH,82H,83H,00H,00HEND。

LCD12864驱动程序(带字库的)

LCD12864驱动程序(带字库的)
/*void delayuS(uchar buf)
{
while(buf--);
}*/
/***********忙检测********************/
void Busy()
{
DataPort=0xFF;
RS=0;
RW=1;
while (1)
{
E =1;
if (P0^7==0) break;
}
E=0;
}
void main(void)
{
TMOD=0x01; ///选择定时器模式
TR0=1; //开中断,并允许T0中断
ET0=1;
EA=1; //总开关
Init_LCቤተ መጻሕፍቲ ባይዱ();
Clear_LCD();
while(1);
}
void t0(void) interrupt 1 using 0
{
//delay(100);
/*void Line_Num(uchar k)
{
//uint l;
if(k>=128&&k<=135)l=1;
if(k>135&&k<=143) l=3;
if(k>143&&k<=151) l=2;
if(k>151&&k<=159) l=4;
}*/
/*******************逐行显示***************************************/
void Write_Data(uchar Data)
{
Busy();
RS=1;
RW=0;

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****** *****************************/。

AVR 单片机驱动12864典型程序

AVR 单片机驱动12864典型程序
// lcd_busy(); //判断LCD忙
RS_0; //指令======= 先写好指令--- 开使能---赋值---关闭使能
RW_0; //写
E_1; // 使能
PORTA=c; //
#include <iom16v.h>
#include <macros.h>
#define uint unsigned int
#define uchar unsigned char
////////////////////////管脚定义及电平///////
#define RS_1 PORTD|=BIT(6); //寄存器选择,高数据
E_0; //
}
//////////////////////////写数据到LCD//////////
void wdata(uchar c)
{
// lcd_busy(); //判断LCD忙
RS_1; //数据========先写好数据--- 开使能---赋值---关闭使能
RST_1;
delay(10);
}
////////////////判断LCD忙函数/////////
/*void lcd_busy(void)
{
uchar busy;
RS_0;
RW_1; //读指令寄存器
PORTA=0x00; //数据口清零
}
E_0;
delay(10); //否则,禁能
}
DDRA=0xff;
E_0; //禁能
}*/
////////////////////////////写指令到LCD/////////

12864液晶屏串口驱动程序

12864液晶屏串口驱动程序

12864液晶屏串口驱动程序代码12864液晶屏驱动采用4_Wire-SPI串口驱动方式,可有效的减少IO口的占用,方便使用调试,本程序的代码驱动IC为ST7565R,是基于STC89C53RC的12864串行模式的程序,硬件电路连接只需要5根线:RS、 SDA、 SCLK、RES、CS 。

程序已经调试通过,很好用。

代码如下://----------------------------------------------------------------------/*hotdisplay CO,.LTD.*/// Module : HTG12864// Lanuage : C51 Code// Create :// Version : 1.0// Date : OCT-21-2016// LCM Drive IC : ST7565R// INTERFACE : 4_Wire-SPI// MCU : STC89C53RC// VDD : 3.3V//********************************************************* ******************#include<reg51.h>#define uchar unsigned char#define uint unsigned intuchar bdata transdata;sbit R_S= P3^5;sbit RES= P3^4;sbit SCK= P1^6;sbit SDA= P1^7;sbit CS1= P3^7;sbit transbit = transdata^7 ;#define Page 0xb0//##########################################//void Comwrite(unsigned char com); //D′??á?3ìDò//void Datawrite(unsigned char dat);void Delay(unsigned int time); //?óê±×ó3ìDò//char code Hanzi[]={0xFF,0x01,0x01,0x09,0xF9,0x09,0x01,0x01,0x09,0xF9,0x09,0xE1 ,0x11,0x09,0x09,0x09,0x11,0xE1,0x01,0x19,0x09,0x09,0xF9,0x09,0x09,0x19,0x01,0x01 ,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x09,0xF9,0x09,0x09,0x09,0x11,0xE1,0x01,0x01 ,0x09,0x09,0xF9,0x09,0x09,0x01,0x01,0x01,0x71,0x89,0x09,0x09,0x09,0x39,0x01,0x09 ,0xF9,0x09,0x09,0x09,0x09,0xF1,0x01,0x01,0x01,0xC1,0x39,0xE1,0x01,0x01,0x01,0x09 ,0xF9,0x09,0x01,0x01,0x01,0x01,0x01,0x09,0x39,0xC9,0x01,0xC9,0x39,0x09,0x01,0x01 ,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x09,0xF9,0x09,0x01,0x01,0x01,0x01,0x01,0xC1 ,0x31,0x09,0x09,0x09,0x09,0x39,0x01,0x09,0xF9,0x09,0x09,0x09,0x11,0xE1,0x01,0x01 ,0x01,0x01,0x01,0xFF,0xFF,0x00,0x00,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,0x0F ,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,0x00 ,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,0x20 ,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,0x20 ,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,0x07 ,0x18,0x20,0x20,0x20,0x10,0x08,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,0x00 ,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0xF8,0x08,0x00 ,0x00,0x08,0xF8,0x08,0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x08,0xF8,0xF8,0x00 ,0xF8,0xF8,0x08,0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x70,0x08,0x08 ,0x08,0x88,0x70,0x00,0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0xE0,0x10,0x88 ,0x88,0x18,0x00,0x00,0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x21,0x01 ,0x01,0x21,0x3F,0x20,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,0x20,0x3F,0x00,0x3F ,0x00,0x3F,0x20,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,0x00,0x30,0x28,0x24 ,0x22,0x21,0x30,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,0x00,0x0F,0x11,0x20 ,0x20,0x11,0x0E,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0xE0,0x10,0x08,0x08 ,0x08,0x10,0xE0,0x00,0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x70,0x88,0x08 ,0x08,0x08,0x38,0x00,0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x10,0x10,0xF8 ,0x00,0x00,0x00,0x00,0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x70,0x88,0x08 ,0x08,0x88,0x70,0x00,0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0xE0,0x10,0x88 ,0x88,0x18,0x00,0x00,0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,0x0F,0x10,0x20,0x20 ,0x20,0x10,0x0F,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,0x00,0x38,0x20,0x21 ,0x21,0x22,0x1C,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x20,0x20,0x3F ,0x20,0x20,0x00,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,0x00,0x1C,0x22,0x21 ,0x21,0x22,0x1C,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,0x00,0x0F,0x11,0x20 ,0x20,0x11,0x0E,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0xFF,0xFF,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x10,0x10,0xF8 ,0x00,0x00,0x00,0x00,0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x08,0x88 ,0x88,0x48,0x30,0x00,0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0xF8,0x08,0x88 ,0x88,0x08,0x08,0x00,0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x38,0x08,0x08 ,0xC8,0x38,0x08,0x00,0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0xE0,0x10,0x08 ,0x08,0x10,0xE0,0x00,0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x10,0x10,0xF8 ,0x00,0x00,0x00,0x00,0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x08,0x88 ,0x88,0x48,0x30,0x00,0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0xF8,0x08,0x88 ,0x88,0x08,0x08,0xFF,0xFF,0x8F,0x90,0xA0,0xA0,0x90,0x8F,0x80,0x80,0xA0,0xA0,0xBF ,0xA0,0xA0,0x80,0x80,0x80,0xB0,0xA8,0xA4,0xA2,0xA1,0xB0,0x80,0x80,0x98,0xA0,0xA0 ,0xA0,0x91,0x8E,0x80,0x80,0x87,0x84,0xA4,0xA4,0xBF,0xA4,0x80,0x80,0x99,0xA1,0xA0 ,0xA0,0x91,0x8E,0x80,0x80,0x8F,0x91,0xA0,0xA0,0x91,0x8E,0x80,0x80,0x80,0x80,0xBF ,0x80,0x80,0x80,0x80,0x80,0x9C,0xA2,0xA1,0xA1,0xA2,0x9C,0x80,0x80,0x80,0xB1,0xA2 ,0xA2,0x91,0x8F,0x80,0x80,0x8F,0x90,0xA0,0xA0,0x90,0x8F,0x80,0x80,0xA0,0xA0,0xBF ,0xA0,0xA0,0x80,0x80,0x80,0xB0,0xA8,0xA4,0xA2,0xA1,0xB0,0x80,0x80,0x98,0xA0,0xA0 ,0xA0,0x91,0x8E,0x80,0x80,0x87,0x84,0xA4,0xA4,0xBF,0xA4,0x80,0x80,0x99,0xA1,0xA0 ,0xA0,0x91,0x8E,0xFF};//###############################################//char code Hanzi1[]={0x00,0x04,0xFC,0x84,0x84,0x84,0x84,0x78,0x00,0x00,0x00,0xA0 ,0xA0,0xA0,0xA0,0xC0,0x00,0x00,0x00,0xC0,0x40,0x20,0x20,0x44,0xFC,0x00,0x00,0x00 ,0x00,0x20,0x20,0xE4,0x00,0x00,0x00,0x00,0x00,0xC0,0x40,0x20,0x20,0x20,0x40,0xC0 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x84,0x84,0x84 ,0x44,0xF8,0x00,0x00,0x00,0x08,0x04,0x04,0x84,0x44,0x38,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x88,0x44,0x44,0x44,0x80,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0xFC,0x30,0xC0,0x00,0xC0,0x30,0xFC,0x04 ,0x04,0xFC,0x44,0x40,0x40,0x40,0x44,0xFC,0x04,0x00,0x60,0x20,0x20,0x20,0xA0,0x60 ,0x20,0x00,0x00,0x00,0x40,0x48,0x4F,0x48,0x40,0x41,0x42,0x4C,0x48,0x40,0x47,0x48 ,0x48,0x48,0x48,0x47,0x48,0x40,0x40,0x47,0x44,0x48,0x48,0x44,0x4F,0x48,0x40,0x40 ,0x40,0x48,0x48,0x4F,0x48,0x48,0x40,0x40,0x40,0x47,0x44,0x48,0x48,0x48,0x44,0x47 ,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x48,0x48,0x48 ,0x44,0x43,0x40,0x40,0x40,0x4C,0x4A,0x49,0x48,0x48,0x48,0x40,0x40,0x40,0x40,0x40 ,0x4C,0x4C,0x40,0x40,0x40,0x40,0x40,0x47,0x48,0x48,0x48,0x48,0x47,0x40,0x40,0x40 ,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x48,0x4F,0x48,0x40,0x43,0x40,0x48,0x4F,0x48 ,0x48,0x4F,0x48,0x40,0x40,0x40,0x48,0x4F,0x48,0x40,0x48,0x4C,0x4A,0x49,0x48,0x48 ,0x4C,0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0xE0,0xE0,0xE0,0xFC,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C ,0x1C,0xFC,0xE0,0xE0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xE0,0xE0,0xFC ,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0xFC,0xE0,0xE0,0xE0,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xE0,0xE0,0xFC,0x1C,0x1C,0x1C,0x1C ,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0xFC,0xE0,0xE0,0xE0,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00 ,0x00,0xF0,0x00,0x00,0x00,0x00,0x80,0x40,0x20,0x10,0x00,0x00,0x80,0x00,0x80,0x80 ,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0xC0,0x30,0x00,0xF0,0x00,0x80 ,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x1F,0x1F,0x1F,0xFF,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0 ,0xE0,0xFF,0x1F,0x1F,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F,0xFF ,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xFF,0x1F,0x1F,0x1F,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F,0xFF,0xE0,0xE0,0xE0,0xE0 ,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xFF,0x1F,0x1F,0x1F,0x00,0x00,0x00,0x00,0x00 ,0x00,0xFF,0x08,0x04,0x02,0x07,0x08,0x30,0x40,0x80,0x00,0x00,0xFF,0x01,0x00,0x00 ,0x00,0xFF,0x01,0x00,0x00,0x00,0xFF,0x00,0xC0,0x3C,0x03,0x00,0x00,0xFF,0x01,0x00 ,0x00,0x00,0xFF,0x00,0x04,0x04,0x84,0x44,0x44,0x44,0x84,0x04,0x04,0x04,0x84,0x44 ,0x44,0x44,0x84,0x04,0x04,0x04,0x84,0x84,0xC4,0x04,0x04,0x04,0x04,0x04,0x84,0x44 ,0x44,0x44,0x84,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x84,0x84 ,0xC4,0x04,0x04,0x04,0x04,0x04,0x84,0x44,0x44,0x44,0x84,0x04,0x04,0x04,0x04,0x04 ,0x04,0x04,0x04,0x04,0x04,0x04,0x84,0x44,0x44,0x44,0x84,0x04,0x04,0x04,0x84,0x44 ,0x44,0x44,0x84,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x84,0x84 ,0xC4,0x04,0x04,0x04,0x04,0x04,0xC4,0x44,0x44,0x44,0x44,0x04,0x04,0x04,0x04,0x04 ,0x04,0x04,0x04,0x04,0x04,0x84,0x44,0x44,0x44,0x84,0x04,0x04,0x04,0xC4,0x44,0x44 ,0x44,0x44,0x04,0x04,0x00,0x00,0x60,0x50,0x48,0x44,0x43,0x00,0x00,0x00,0x3F,0x40 ,0x40,0x40,0x3F,0x00,0x00,0x00,0x40,0x40,0x7F,0x40,0x40,0x00,0x00,0x00,0x3F,0x40 ,0x40,0x40,0x3F,0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,0x40,0x40 ,0x7F,0x40,0x40,0x00,0x00,0x00,0x60,0x50,0x48,0x44,0x43,0x00,0x00,0x08,0x08,0x08 ,0x08,0x08,0x08,0x08,0x00,0x00,0x20,0x40,0x44,0x44,0x3B,0x00,0x00,0x00,0x3F,0x40 ,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40 ,0x7F,0x40,0x40,0x00,0x00,0x00,0x27,0x44,0x44,0x44,0x38,0x00,0x00,0x00,0x00,0x00 ,0x21,0x00,0x00,0x00,0x00,0x60,0x50,0x48,0x44,0x43,0x00,0x00,0x00,0x27,0x44,0x44 ,0x44,0x38,0x00,0x00,};void Delay(unsigned int time){unsigned char j;while(time--){for(j=0;j<=50;j++){}}}/******************************************************/ void Display(unsigned char sda,unsigned char sda1){unsigned char i,j,k=0;Comwrite(0x40);for(i=0;i<8;i++){Comwrite(Page+k);Comwrite(0x10);Comwrite(0x00);for(j=0;j<66;j++){Datawrite(sda);Datawrite(sda1);}k++;}}/*****************************************************/void Hanzi_Disp(void){unsigned char i,j,k=0;Comwrite(0x40);for(i=0;i<8;i++){Comwrite(Page+k);Comwrite(0x10);Comwrite(0x00);for(j=0;j<128;j++){Datawrite(Hanzi[i*128+j]);}k++;}Delay(5000);}void Hanzi_Disp1(void){unsigned char i,j,k=0;Comwrite(0x40);for(i=0;i<8;i++){Comwrite(Page+k);Comwrite(0x10);Comwrite(0x00);for(j=0;j<128;j++){Datawrite(Hanzi1[i*128+j]);}k++;}Delay(5000);}//######################################################### void Intial(void){Delay(100);Comwrite(0xe3);Comwrite(0xA2);Comwrite(0xA0); //A0为正显示,A1为镜像显示Comwrite(0xc9);Comwrite(0x2c);Comwrite(0x2e);Comwrite(0x2F);Comwrite(0xf8);Comwrite(0x00);Comwrite(0x81);Comwrite(0x10);Comwrite(0x25);Comwrite(0xAF);Comwrite(0x40);Delay(20);}/********************************************************** /int main(){/*PINSEL0=0x00000000; IO0DIR=SPIIOCON;RES=0;Delay(20);RES=1;Delay(20);while(1){Intial();Delay(20);Display(0xFF,0xFF);Delay(1000);Display(0x00,0x00);Delay(1000);Display(0xFF,0x00);Delay(1000);Display(0x00,0xff);Delay(1000);Display(0x55,0xAA);Delay(1000);Display(0xAA,0x55);Delay(1000);Hanzi_Disp(); Delay(1000);Hanzi_Disp1();Delay(1000);}}//###############################################// void Comwrite(char com){unsigned char data i;transdata=com;CS1=0;R_S=0;SCK=1;for(i=0;i<8;i++){SDA=transbit;SCK=0;SCK=1;transdata=transdata<<1;}CS1=1;R_S=0;}//######################################################### ##//void Datawrite(char dat){unsigned char data i;transdata=dat;CS1=0;R_S=1;SCK=1;for(i=0;i<8;i++){SDA=transbit;SCK=0;SCK=1;transdata=transdata<<1;}CS1=1;R_S=0;}以上是鑫洪泰的小编为你带来的12864液晶屏驱动程序编写示例,如果你想有更进一步的了解,请您关注我们微信,或者点击我们官网了解我们,也可以在线咨询或者拨打我们的热线电话与我们联系!我们会有专业的工作人员为你实时解答。

12864液晶经典驱动程序,一看就懂,有详细的注释(C语言编写,不看后悔)

12864液晶经典驱动程序,一看就懂,有详细的注释(C语言编写,不看后悔)

这个程序写得很好,自己也是看的别人写的很好的程序,但是它代码不够完整,注释不详细,经过自己的修改加以完善。

另外我发现很多的测试代码都没有附上测试代码效果图,在本人的代码下面有自己拍的效果图,填补不足之处。

自己在找资料的过程中花掉很多的财富值,如果大家看得起该代码请评五分加以下载,在下感激不尽!/*******************************************程序名称:12864液晶经典驱动程序(带中文字库)功能:12864测试程序修改作者:王程修改时间:2014年2月5日23:22:32********************************************/#include<reg52.h>#define uchar unsigned char#define uint unsigned int// P0 为数据口sbit LCD_RS=P2^0; //数据、命令选择端口sbit LCD_RW=P2^1; //液晶读写控制sbit LCD_EN=P2^2; //液晶使能控制sbit PSB = P2^4; //模式选择1为并行0为串行sbit RES = P2^5;//复位端口低电平复位,上电之前进行复位,为了稳定!unsigned char code DAT[] = "我爱我家"; //测试显示的汉字,下面的A为测试显示的英文/*******************************************函数名称:Delay_1ms (晶振为12M)功能:延时约1ms的时间参数:无返回值:无********************************************/void delay_1ms(uint x){uint i,j;for(j = 0;j < x;j++)for(i=0;i<110;i++);}/*******************************************函数名称:write_cmd功能:向液晶中写控制命令参数:cmd--控制命令返回值:无********************************************/void write_cmd(uchar cmd){uchar lcdtemp = 0;LCD_RS=0;LCD_RW=1;do //经典判忙方式,精简{LCD_EN=1;delay_1ms(2);lcdtemp = P0;LCD_EN=0;}while(lcdtemp & 0x80);LCD_RW=0;P0 = cmd;LCD_EN=1;delay_1ms(5);LCD_EN=0;}/*******************************************函数名称:write_data功能:向液晶中写显示数据参数:dat--显示数据返回值:无********************************************/ void write_data(uchar dat){uchar lcdtemp = 0;LCD_RS=0;LCD_RW=1;do //经典判忙方式{LCD_EN=1;delay_1ms(2);lcdtemp = P0;LCD_EN=0;}while(lcdtemp & 0x80);LCD_RS=1;LCD_RW=0;P0 = dat;LCD_EN=1;delay_1ms(5);LCD_EN=0;}/*******************************************函数名称:lcd_int功能:初始化液晶模块参数:无返回值:无********************************************/void lcd_int(void){delay_1ms(40); //大于40MS的延时程序PSB=1; //设置为8BIT并口工作模式delay_1ms(1); //延时RES=0; //复位delay_1ms(1); //延时RES=1; //复位置高delay_1ms(10);write_cmd(0x30); //基本指令集delay_1ms(5);write_cmd(0x30); //基本指令集delay_1ms(5);write_cmd(0x08); // 地址归位delay_1ms(5);write_cmd(0x10); //光标设置delay_1ms(5);write_cmd(0x0c); //整体显示打开,游标关闭delay_1ms(5);write_cmd(0x01); //清除显示delay_1ms(5);write_cmd(0x06); //游标右移delay_1ms(5);write_cmd(0x80); //设定显示的起始地址delay_1ms(5);}函数名称:main功能:测试1602初始化函数模块参数:无返回值:无********************************************/void main(){uchar i;char *a = DAT;//使用指针,指向字符串地址lcd_int();write_data('A'); //每个显示都是用的两个字节,必须写两次write_data(' ');//再写一次,不然乱显示(如果不加就再显示一个别的字母)for(i=0;i<8;i++){write_data(*a);//将地址当作数据传给12864a++;//一个汉字传送两次,因为一个汉字占用两个字节,两次传完}write_cmd(0x90);//一行显示八个汉字,第一行0x80-87,第二行0x90开始a = DAT;for(i=0;i<8;i++){write_data(*a);a++;}while(1); //停住,不然重复的初始化显示,作为测试用}/*******************************************代码测试效果图片两两张由于曝光度影响,拍了两张********************************************/。

LCD12864液晶驱动程序

LCD12864液晶驱动程序

/ void LCD_12864_Write_Data(uchar dat) { LCD_12864_BUSY_WAIT(); LCD_12864_RS_1(); LCD_12864_RW_0(); LCD_12864_DATA=dat; LCD_12864_E_1(); LCD_12864_E_0(); } /****************************************************************************** * Function:void LCD_12864_Init(void) Description:液晶初始化 Calls:LCD_12864_Write_Command(); CallS By:Sytem_Init.c 中的 System_Init() Input: None Output:None Others: ******************************************************************************* / void LCD_12864_Init(void) { /*光标的移动方向*/ LCD_12864_Write_Command(0x06); /*开显示,关游标*/ LCD_12864_Write_Command(0x0C); /*开显示,开游标*/ //LCD_12864_Write_Command(0x0F); /*基本指令动作*/ LCD_12864_Write_Command(0x30); } /****************************************************************************** * Function:void LCD_12864_Clean_GDRAM(void) Description:清屏,GDRAM 填满 0 Calls:LCD_12864_Init(); LCD_12864_Write_Command(0x36); LCD_12864_Write_Data(0x00);

12864点阵型驱动程序(51单片机、c语言)

12864点阵型驱动程序(51单片机、c语言)
** 函 数 名:asc()
** 功能描述:在液晶显示器上写一个ASCII字符,写之前需要使用setxy()函数确定位置
** 输入参数:uchar ascii:字符对应的ascii码
** 输出参数:
** 返 回 值:
** 作 者:xiwangcumt
** 日 期:
**********************************************************/
** 功能描述:C语言下最精确最简单的延时函数,延时时间为2*t+2(us)
** 输入参数:t-延时时间参数
** 输出参数:
** 返 回 值:
** 作 者:xiwangcumt
** 日 期:
**********************************************************/
void setp(uchar n)
{
switch(n){
case 0: cs1=1;cs2=1; break;
case 1: cs1=1;cs2=0; break;
case 2: cs1=0;cs2=1; break;
default:break;}
}
/*********************************************************
** 输入参数:uchar dat
** 输出参数:
** 返 回 值:
** 作 者:xiwangcumt
** 日 期:
**********************************************************/

12864液晶屏驱动程序

12864液晶屏驱动程序
unsigned char BMPheight;
BMPwith=*PicData;
PicData++;
BMPheight=(*PicData)/8;
PicData++;
//BMPLen=BMPheight/8*BMPwith
for(BMPheightLen=0;BMPheightLen<BMPheight;BMPheightLen++)
Series = Series << 1;
}
}
/***********************************
** 函数名称: Write_Data
** 功能描述: 传送数据
** 输 入: dat
** 输 出 : 无
** 全局变量:无
** 调用模块: Busy,
******************************************/
//图像反色显示 0 否 1是
bit LCD_DisplayReserve_Driver;
//定义LCD显示的全局变量
#define CS_Port P3_0
#define A0_Port P3_1
#define SI_Port P3_2
{
switch (PIN)
{
case CS :
CS_Port=1;
break;
case A0 :
A0_Port=1;
break;
case SI :
SI_Port=1;
break;
case SCL :
SCL_Port=1;

AMPIRE12864驱动程序

AMPIRE12864驱动程序

AMPIRE12864驱动程序一、芯片介绍AMPIRE12864图形点阵液晶显示器,它主要采用动态驱动原理由行驱动&mdash;控制器和列驱动器两部分组成了128(列)&times;64(行)的全点阵液晶显示。

可显示8&times;4个16&times;16点阵汉字或16&times;4个16&times;8点阵ASCII字符集,也可完成图形的显示。

与CPU接口采用5条位控制总线和8位并行数据总线输入输出,具有4位/8位并行、2线或3线串行多种接口方式。

AMPIRE12864共18个引脚其中包括8个三态数据引脚,5个控制信号引脚,1个复位引脚和4个电源相关引脚。

AMPIRE12864详细引脚描述见表2-7。

表2-7AMPIRE12864详细引脚描述引脚号引脚名称级别引脚功能描述3GND电源地4VCC+5V电源电压5V00~-10VLCD驱动负电压,要求VDD-VLCD=13V 6RSH/L寄存器选择信号7R/WH/L读/写操作选择信号8EH/L使能信号DB0H/L八位三态并行数据总线10DB111DB212DB313DB414DB515DB616DB71CS1H/L片选信号,当CS1=H时,液晶左半屏显示CS2H/L片选信号,当CS2=H时,液晶右半屏显示 17/RSTH/L复位信号,低电平有效18Vout-10V输出-10V的负电压(单电源供电) AMPIRE12864引脚图如图2-7所示。

图2-7AMPIRE12864引脚图1)AMPIRE12864液晶显示器主要硬件构成AMPIRE12864液晶显示器主要包括以下几个硬件模块:① 显示数据RAM(DDRAM)DDRAM(64&times;8&times;8 bits)是存储图形显示数据的。

此RAM的每一位数据对应显示面板上一个点的显示(数据为H)与不显示(数据为L)。

DDRAM的地址与显示位置关系对照如表2-8所示。

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液晶4位并行接口驱动程序

12864液晶4位并行接口驱动程序

12864液晶4位并行接口驱动程序#include#include#include#include#define uchar unsigned char#define uint unsigned int#define DATA 1#define COMMAND 0sbit rs=P2^4;sbit rw=P2^5;sbit en=P2^6;sbit psb=P2^1;sbit rst=P2^3;sbit key=P1^0;uchar code AC_TABLE[]={0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, //第一行汉字位置0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97, //第二行汉字位置0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f, //第三行汉字位置0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f, //第四行汉字位置};uchar code str1[]="黄河远上白云间,一片孤城万仞山。

羌笛何须怨杨柳,春风不度玉门关。

";uchar code bmp1[]={//********************************************************//// 位图点阵占用1024字节//********************************************************//0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0 xFF,0x FF,0xFF,0xFF,0x80,0x00,0x0F,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x70,0x00, 0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00, 0x00,0x01,0x80,0x00,0x3F,0xC0,0x00,0x07,0x07,0x00,0x04,0x01,0x00,0x 00,0x38,0x60, 0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00, 0x00,0x01,0x80,0x00,0x78,0xE0,0x00,0x3F,0x83,0x80,0x06,0x03,0x80,0x 00,0x1C,0x70, 0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00, 0x00,0x01,0x80,0x02,0x38,0x70,0x00,0xFF,0x07,0x80,0x06,0x39,0x80,0x 00,0x1F,0x70, 0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00, 0x00,0x01,0x80,0x02,0x1C,0x30,0x00,0x7C,0x0E,0x00,0x06,0x19,0xC0,0 x00,0x1F,0x8 0,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00, 0x00,0x01,0x80,0x02,0x1C,0x30,0x00,0x3E,0x1C,0x00,0x06,0x1F,0xC0,0x 00,0x7F,0x0 0,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00, 0x00,0x01,0x80,0x03,0x3E,0x30,0x00,0x62,0x1A,0x00,0x0F,0x79,0x00,0x 03,0xFE,0x00 ,0x00,0x01,0x80,0x00,0x00,0x60,0x0F,0x00,0x3F,0x00,0x00,0x00,0x3C,0x 00,0xC0,0x00 ,0x00,0x01,0x80,0x07,0x76,0x18,0x00,0xC3,0xC1,0x00,0x1F,0xFB,0x00,0x 03,0xFE,0x0 0,0x00,0x01,0x80,0x00,0x01,0xE0,0x3F,0xC0,0xF1,0xC0,0x00,0x00,0xF0,0x 01,0xC0,0x0 0,0x00,0x01,0x80,0x07,0x6E,0x18,0x00,0xCF,0xC1,0x80,0x7E,0x3F,0x80,0x 01,0xE2,0x0 0,0x00,0x01,0x80,0x00,0x07,0xE0,0x7F,0xE0,0xE0,0xE0,0x00,0x03,0xC0,0x 03,0xC0,0x0 0,0x00,0x01,0x80,0x07,0x7F,0x98,0x00,0xFE,0x83,0x81,0xFC,0x1E,0xC0,0x 00,0x83,0x0 0,0x00,0x01,0x80,0x00,0x0F,0xE0,0x63,0xE1,0xE0,0xE0,0x00,0x07,0x00,0x 03,0xC0,0x0 0,0x00,0x01,0x80,0x06,0xFF,0xD8,0x01,0xFA,0x87,0x00,0xFD,0xF8,0xC0,0x 01,0x73,0x0 0,0x00,0x01,0x80,0x00,0x01,0xE0,0xC1,0xE1,0xE0,0xE0,0x00,0x0F,0x00,0x 07,0xC0,0x0 0,0x00,0x01,0x80,0x0F,0xD9,0xD8,0x03,0xE3,0x0E,0x80,0xFE,0x7E,0xC0,0 x03,0xF9,0x8 0,0x00,0x01,0x80,0x00,0x01,0xE0,0x01,0xE1,0xF0,0xE0,0x00,0x1E,0x00,0x 0B,0xC0,0x0 0,0x00,0x01,0x80,0x0D,0xB8,0x18,0x1F,0xC3,0x08,0xC0,0x0E,0x6D,0x80,0 x03,0xF1,0x8 0,0x00,0x01,0x80,0x00,0x01,0xE0,0x01,0xE0,0xFD,0xC7,0xEF,0x9E,0x00,0x 13,0xC0,0x0 0,0x00,0x01,0x80,0x0D,0xFE,0x18,0x0F,0xC2,0x10,0xE0,0x1C,0x3F,0x00,0x 03,0xE0,0xC 0,0x00,0x01,0x80,0x00,0x01,0xE0,0x01,0xC0,0xFF,0x83,0xC6,0x1F,0xE0,0x 13,0xC0,0x0 0,0x00,0x01,0x80,0x0D,0xCE,0x18,0x06,0xC2,0x01,0xC0,0x38,0x3E,0x00,0 x00,0xE8,0xC 0,0x00,0x01,0x80,0x00,0x01,0xE0,0x01,0x80,0x3F,0x81,0xE4,0x3C,0x78,0x 23,0xC0,0x00 ,0x00,0x01,0x80,0x0C,0x4C,0x18,0x00,0xC2,0x03,0x80,0x78,0x1F,0xF0,0x 00,0xFC,0x6 0,0x00,0x01,0x80,0x00,0x01,0xE0,0x03,0x80,0x3F,0xC1,0xE8,0x3C,0x78,0x 43,0xC0,0x0 0,0x00,0x01,0x80,0x0C,0x5E,0x18,0x00,0xC2,0x07,0x00,0x68,0x3F,0xF8,0x 03,0xFC,0x2 2,0x00,0x01,0x80,0x00,0x01,0xE0,0x03,0x00,0x6F,0xC0,0xF0,0x3C,0x3C,0x 83,0xC0,0x0 0,0x00,0x01,0x80,0x06,0x3F,0x38,0x01,0x82,0x0E,0x00,0x09,0xF8,0x00,0x 03,0xC0,0x32 ,0x00,0x01,0x80,0x00,0x01,0xE0,0x06,0x00,0xC3,0xE0,0x78,0x3C,0x3C,0 xFF,0xF0,0x0 0,0x00,0x01,0x80,0x07,0x10,0x38,0x00,0x82,0x1C,0x00,0x0B,0x99,0xC0,0 x03,0x00,0x1A ,0x00,0x01,0x80,0x00,0x01,0xE0,0x0C,0x11,0xC3,0xE0,0x78,0x3C,0x3C,0 xFF,0xF0,0x0 0,0x00,0x01,0x80,0x03,0xFF,0xF0,0x00,0x02,0x38,0x00,0x08,0x30,0xE0,0x 02,0x00,0x1E ,0x00,0x01,0x80,0x00,0x01,0xE0,0x08,0x11,0xC1,0xE0,0x7C,0x3C,0x3C,0 xFF,0xF0,0x0 0,0x00,0x01,0x80,0x01,0xEF,0xF0,0x00,0x00,0xE0,0x00,0x08,0xE0,0x60,0x 00,0x00,0x0E ,0x00,0x01,0x80,0x00,0x01,0xE0,0x1F,0xF1,0xC1,0xE0,0xBC,0x1C,0x3C,0 x03,0xC0,0x 00,0x00,0x01,0x80,0x00,0x03,0xE0,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x 00,0x00,0x07, 0x00,0x01,0x80,0x00,0x01,0xE0,0x3F,0xE1,0xC1,0xC0,0x9E,0x1E,0x38,0x 03,0xC0,0x0 0,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x01, 0x00,0x01,0x80,0x00,0x01,0xF0,0x7F,0xE0,0xE3,0x83,0x1F,0x0E,0x70,0x 03,0xC0,0x0 0,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00, 0x00,0x01,0x80,0x00,0x0F,0xFC,0xFF,0xE0,0x3F,0x07,0xDF,0x83,0xE0,0x 03,0xC0,0x0 0,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00, 0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00, 0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00, 0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00, 0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00, 0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00, 0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00, 0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00, 0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00, 0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00, 0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00, 0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00, 0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00, 0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x60,0x00, 0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0 xFF,0x FF,0xFF,0xFF,};void writeByte(uchar flag,uchar content);void delayUs(uint z){while(z--);}void delay1MS(uchar x){uchar k,j;x=x<<1;for(k=0;k<x;k++)< p="">for(j=0;j<255;j++)_nop_();}/*------------------------------------------------检测忙位------------------------------------------------*/void CheckBusy(){uchar temp1,temp2;do{en=0;delayUs(5);rs=0;rw=1;en=1;temp1=P0; //读高字节delayUs(10);en=0;delayUs(5);rs=0;rw=1;en=1;temp2=P0; //读低字节en=0;/*数据处理*/temp1=temp1&0xf0;temp2=(temp2&0xf0)>>4;temp1=(temp1+temp2);}while((temp1&0x80)==0x80);}void init(){rst=0;delayUs(40);rst=1;delayUs(40);psb=1;delayUs(8);writeByte(COMMAND,0x20); //基本指令集4bit数据delayUs(8);writeByte(COMMAND,0x01);delayUs(8);writeByte(COMMAND,0x06);delayUs(8);writeByte(COMMAND,0x0c);delayUs(8);}/************************************************************** ************************** *** 函数名称:SendByte* 功能描述:串口发送一个字节*flag=1,写入数据。

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

///////////////////////////////////////////////////////////#include<reg52.h>#include<absacc.h>#define uchar unsigned char#define uint unsigned int//////////单片机与液晶显示的引脚连接///////// sbit P32=P3^2; //RSTsbit P33=P3^3; //CS2sbit P34=P3^4; //CS1sbit P35=P3^5; //Esbit P36=P3^6; //rs&DIsbit P37=P3^7; // R/W////////延时/////////void delay(uint v){while(v!=0)v--;}////////复位///////////void reset(){P32=0;delay(10);P32=1;delay(10);}////////write code写指令///////void wcode(uchar c,uchar cs1,uchar cs2) {P34=cs1;P33=cs2;P37=0;P36=0;P1=c;P35=0;delay(10);P35=1;delay(10);P35=0;}/////////write data写数据///////////////void wdata(uchar c,uchar cs1,uchar cs2){P34=cs1;P33=cs2;P37=1;P36=0;P1=c;P35=0;delay(10);P35=1;delay(10);P35=0;}////////////set start设置起始行/////////////void set_startline(uchar i)//起始行。

11A5A4A3A2A1A0 共有64行// 液晶显示器的最底层为第一行{i=0xc0+64-i;//此算法为把最顶层做为第一层wcode(i,1,1);}////////////set 页值设置,起始列值函数/////////////void set_adr(uchar x,uchar y){x=x+0xb8;//页地址设置。

10111A2A1A0 DDRAM的8行为一页,A0~A2为页码,LCD为64行8页y=y+0x40;//列地址设置。

01A5A4A3A2A1A0 两半屏分别有64列,A0~A5送入列地址计数器,//作为列(Y)地址指针。

每读写一次其自动加一,指向下一列DDRAM单元wcode(x,1,1);wcode(y,1,1);}///////////on/off开/关显示函数//////////////void dis_on_off(uchar o){o=0x3e+o;//0011111D D=1开显示器把RAM数据呈现在显示器上,D=0关显示,但数据仍储存在RAM内。

wcode(o,1,1);}///////////clear清屏///////////////void clear(){uchar i,loop;for(i=0;i<8;i++)///循环页写0/////////{set_adr(i,0);for(loop=0;loop<64;loop++)wdata(0x00,1,1);}}/////////////////////////////////////////////////////////////////////////// 汉字字模表//// 汉字库: 宋体16.dot 纵向取模下高位,数据排列:从左到右从上到下///////////////////////////////////////////////////////////////////////////uchar code xian[32]= // "现"{0x04,0x84,0x84,0xFC,0x86,0x84,0x00,0xFE,0x02,0x82,0x7A,0x02,0xFF,0x02,0x00,0x00,0x10,0x30,0x10,0x1F,0x88,0x88,0x40,0x23,0x18,0x07,0x78,0x80,0x83,0x80,0xE0,0x00,};uchar code zai[32]= //"在"{0x08,0x08,0x08,0x08,0xC8,0x38,0x0F,0x08,0x08,0xE8,0x08,0x88,0x08,0x0C,0x08,0x00,0x08,0x04,0x02,0xFF,0x00,0x40,0x41,0x41,0x41,0x7F,0x41,0x41,0x41,0x60,0x40,0x00,};uchar code wen[32]= //"温"{0x10,0x22,0x64,0x0C,0x80,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0xFF,0x02,0x00,0x00,0x7E,0x42,0x7E,0x42,0x42,0x7E,0x40,0x00, };uchar code du[32]= //"度"{0x00,0x00,0xFC,0x24,0x24,0x24,0xFC,0xA5,0xA6,0xA4,0xFC,0x24,0x34,0x26,0x04,0x00,0x40,0x20,0x9F,0x80,0x42,0x42,0x26,0x2A,0x12,0x2A,0x26,0x42,0x40,0xC0,0x40,0x00 };uchar code maohao[16]= // -:-{ 0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x00,0x00,0x00,};uchar code wu[16]= // -5-{ 0x7C,0x7C,0x44,0x44,0xC4,0xC4,0x84,0x00,0x04,0x0C,0x08,0x08,0x08,0x0F,0x07,0x00,};uchar code er[16]= // -2-{ 0x08,0x0C,0x84,0xC4,0x64,0x3C,0x18,0x00,0x0E,0x0F,0x09,0x08,0x08,0x0C,0x0C,0x00,};uchar code san[16]= // -3-{ 0x08,0x0C,0x44,0x44,0x44,0xFC,0xB8,0x00,0x04,0x0C,0x08,0x08,0x08,0x0F,0x07,0x00,};uchar code li[32] = //"理"{0x44,0x44,0xFC,0x46,0x44,0x00,0xFE,0x92,0x92,0xFE,0x92,0x92,0xFF,0x02,0x00,0x00,0x10,0x30,0x1F,0x08,0x48,0x48,0x44,0x44,0x44,0x7F,0x44,0x46,0x44,0x60,0x40,0x00, };uchar code gong[32] = // "工",{0x00,0x04,0x04,0x04,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x06,0x04,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x30,0x20,0x00, };uchar code xue[32] = //"学",{0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,0x04,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,0x06,0x05,0x04,0x04,0x04,0x06,0x04,0x00, };uchar code yuan[32] = //院{0x00,0xFE,0x22,0x5A,0x96,0x0C,0x24,0x24,0x25,0x26,0x24,0x34,0xA4,0x14,0x0C,0x00,0x00,0xFF,0x04,0x08,0x87,0x81,0x41,0x31,0x0F,0x01,0x3F,0x41,0x41,0x41,0x70,0x00, };uchar code dian[32] = //"电",{0x00,0xF8,0x48,0x48,0x48,0x48,0xFF,0x48,0x48,0x48,0x48,0xFC,0x08,0x00,0x00,0x00,0x00,0x07,0x02,0x02,0x02,0x02,0x3F,0x42,0x42,0x42,0x42,0x47,0x40,0x70,0x00,0x00, };uchar code zi[32] = //"子",{0x80,0x80,0x82,0x82,0x82,0x82,0x82,0xE2,0xA2,0x92,0x8A,0x86,0x80,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, };uchar code chuang[32] = //"创",{0x80,0x40,0xF0,0x4C,0x43,0x44,0xC8,0x10,0x30,0x00,0xF8,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x3F,0x40,0x42,0x44,0x43,0x70,0x00,0x00,0x07,0x40,0x80,0x7F,0x00,0x00, };uchar code xin[32] = //"新",{0x40,0x44,0x54,0x65,0xC6,0x64,0xD6,0x44,0x40,0xFC,0x44,0x42,0xC3,0x62,0x40,0x00,0x20,0x11,0x49,0x81,0x7F,0x01,0x05,0x29,0x18,0x07,0x00,0x00,0xFF,0x00,0x00,0x00, };uchar code shi[32] = //"实",{0x10,0x0C,0x04,0x44,0x8C,0x94,0x35,0x06,0xF4,0x04,0x04,0x04,0x04,0x14,0x0C,0x00,0x02,0x82,0x82,0x42,0x42,0x23,0x12,0x0E,};uchar code yan[32] = //"验",{0x02,0xFA,0x02,0x02,0xFF,0x42,0x20,0x50,0x4C,0x43,0x4C,0x50,0x20,0x60,0x20,0x00,0x10,0x31,0x11,0x49,0x89,0x7F,0x42,0x5C,0x40,0x4F,0x60,0x58,0x47,0x60,0x40,0x00, };uchar code ban[32] = //"班",{0x84,0x84,0xFC,0x84,0x06,0xF4,0x00,0xFF,0x00,0x84,0x84,0xFC,0x84,0x86,0x04,0x00,0x20,0x60,0x3F,0x10,0x92,0x41,0x38,0x07,0x40,0x40,0x40,0x7F,0x40,0x60,0x40,0x00 };uchar code xie[32]= //"谢"{0x40,0x42,0xCC,0x00,0xFC,0x56,0x55,0x54,0xFE,0x24,0x20,0x20,0xFF,0x20,0x20,0x00,0x00,0x00,0x3F,0x52,0x2B,0x12,0x4A,0x86,0x7F,0x01,0x46,0x80,0x7F,0x00,0x00,0x00, };uchar code guo[32]= //"国"{0x00,0xFE,0x02,0x0A,0x8A,0x8A,0x8A,0xFA,0x8A,0xCA,0x8E,0x0A,0x02,0xFF,0x02,0x00,0x00,0xFF,0x40,0x50,0x50,0x50,0x50,0x5F,0x50,0x52,0x54,0x50,0x40,0xFF,0x00,0x00, };uchar code hua[32]= //"华"{0x00,0x40,0x20,0x10,0xFC,0x03,0x40,0x20,0x10,0xFF,0x08,0x04,0x06,0xC0,0x00,0x00,0x04,0x04,0x04,0x04,0x05,0x04,0x04,0xFF,0x04,0x04,0x05,0x05,0x05,0x05,0x04,0x00, };//////////////main////////////////void main(){uchar loop;reset();//复位dis_on_off(1);///开关开,把RAM数据呈现在显示器上set_startline(10);//从第0行开始显示clear();//清屏while(1){//以下为字符显示程序,主要程序思路为分左右屏写,同一页同一行内按左到右踔厉风顺序写//同一字符分上下16半个字写代码set_adr(0,32);for(loop=0;loop<16;loop++) wdata(xian[loop],1,0);for(loop=0;loop<16;loop++) wdata(zai[loop],1,0);set_adr(1,32);for(loop=16;loop<32;loop++) wdata(xian[loop],1,0);for(loop=16;loop<32;loop++) wdata(zai[loop],1,0);set_adr(0,0);for(loop=0;loop<16;loop++) wdata(wen[loop],0,1);for(loop=0;loop<16;loop++) wdata(du[loop],0,1);set_adr(1,0);for(loop=16;loop<32;loop++) wdata(wen[loop],0,1);for(loop=16;loop<32;loop++) wdata(du[loop],0,1);///////////////////////////////////////////////////第一行显示现在温度/*set_adr(0,32);for(loop=0;loop<8;loop++) wdata(maohao[loop],0,1);set_adr(1,32);for(loop=8;loop<16;loop++) wdata(maohao[loop],0,1);set_adr(2,45);for(loop=0;loop<8;loop++)wdata(wu[loop],1,0);for(loop=0;loop<8;loop++)wdata(er[loop],1,0);set_adr(3,45);for(loop=8;loop<16;loop++)wdata(wu[loop],1,0);for(loop=8;loop<16;loop++)wdata(er[loop],1,0);set_adr(2,0);for(loop=0;loop<8;loop++)wdata(san[loop],0,1);set_adr(3,0);for(loop=8;loop<16;loop++)wdata(san[loop],0,1);*/set_adr(2,32);for(loop=0;loop<16;loop++)wdata(li[loop],1,0);for(loop=0;loop<16;loop++)wdata(gong[loop],1,0);set_adr(3,32);for(loop=16;loop<32;loop++)wdata(li[loop],1,0);for(loop=16;loop<32;loop++)wdata(gong[loop],1,0);set_adr(2,0);for(loop=0;loop<16;loop++)wdata(xue[loop],0,1);for(loop=0;loop<16;loop++)wdata(yuan[loop],0,1);set_adr(3,0);for(loop=16;loop<32;loop++)wdata(xue[loop],0,1);for(loop=16;loop<32;loop++)wdata(yuan[loop],0,1);///////////////////////////////////////////////////第一行显示理工学院set_adr(0,16);for(loop=0;loop<16;loop++)wdata(chuang[loop],1,0);set_adr(4,16);for(loop=0;loop<16;loop++)wdata(xin[loop],1,0);set_adr(0,32);for(loop=0;loop<16;loop++)wdata(shi[loop],0,1);set_adr(1,16);for(loop=16;loop<32;loop++)wdata(chuang[loop],1,0);set_adr(5,16);for(loop=16;loop<32;loop++)wdata(xin[loop],1,0);set_adr(1,32);for(loop=16;loop<32;loop++)wdata(shi[loop],0,1);// set_adr(4,0);//for(loop=8;loop<16;loop++) wdata(shi[loop],0,1);set_adr(2,32);for(loop=0;loop<16;loop++) wdata(yan[loop],0,1);set_adr(4,32);for(loop=0;loop<16;loop++) wdata(ban[loop],0,1);//set_adr(5,0);//for(loop=24;loop<32;loop++) wdata(shi[loop],0,1);set_adr(3,32);for(loop=16;loop<32;loop++) wdata(yan[loop],0,1);set_adr(5,32);for(loop=16;loop<32;loop++) wdata(ban[loop],0,1);///////////////////////////////////////////////////第三行显示创新实验班set_adr(4,32);for(loop=0;loop<16;loop++) wdata(xie[loop],1,0);for(loop=0;loop<16;loop++) wdata(guo[loop],1,0);set_adr(5,32);for(loop=16;loop<32;loop++) wdata(xie[loop],1,0);for(loop=16;loop<32;loop++) wdata(guo[loop],1,0);set_adr(4,0);for(loop=0;loop<16;loop++) wdata(hua[loop],0,1);set_adr(5,0);for(loop=16;loop<32;loop++) wdata(hua[loop],0,1);////////////////////////////////////////////////////第四行显示谢国华}}。

相关文档
最新文档