12864串行51程序

合集下载

12864液晶显示程序51驱动

12864液晶显示程序51驱动

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

51单片机12864万年历(图片+主要程序C语言)

51单片机12864万年历(图片+主要程序C语言)

51单片机做的12864万年历这是我花了一个星期时间做的万年历;一开始是一些图片,后面是这个制作的C语言源程序;希望大家稀饭:Main.c#include "reg52.h"#include "macroconst.h"#include "keyscan.h"#include "screen.h"#include "18b20.h"#include "ds1302.h"#include "atao_12864.h"#include "24c02.h"idata unsigned char state1[1];unsigned char screennum=1;//屏幕号#define time_task_sec 200 //节拍200Hz#define clock 24000000 //晶振#define max_task 4 //最大任务数idata unsigned char task_delay[4];#define task_delay0 time_task_sec/1 //2赫兹18b20 #define task_delay1 time_task_sec/5 //10赫兹屏幕#define task_delay2 time_task_sec/3 //4赫兹1302 #define task_delay3 time_task_sec/20 //20赫兹键盘void init(){unsigned char i;init18b20();ds1302_init();initina1(); //---------------------------LCD字库初始化程序RdFromROM(state1,8,1);state[0]=state1[0]; //-------界面RdFromROM(state1,15,1);state[1]=state1[0];//------- 闹钟RdFromROM(state1,11,1);key_sound=state1[0];//-------按键音// state[2]=state1[2];// state[3]=state1[3];screennum=1;//------默认一号屏for(i=0;i<max_task;i++)//清除任务延时{task_delay[i]=0;}TMOD=0x11;EA=1;TH0=255-clock/time_task_sec/12/526;TL0=255-clock/time_task_sec/12%526;ET0=1;TR0=1;}void main(){init();while(1){ if(task_delay[0]==0){readtemp(); task_delay[0]=task_delay0;} if(task_delay[3]==0){MenuCheckKey();task_delay[3]=task_delay1;}if(task_delay[1]==0){screen_select(screennum);task_delay[1]=task_delay1;} if(task_delay[2]==0){ds1302_read_time(); task_delay[2]=task_delay0;} }}void timer0() interrupt 1{uchar i=0;TH0=255-clock/time_task_sec/12/526;TH1=255-clock/time_task_sec/12%526;for(i=0;i<max_task;i++)if(task_delay[i]) task_delay[i]--; // miao=21,fen=33,xiaomiao=94;if(ma_start==1){tt++;if(tt==8){tt=0;xiaomiao++;if(xiaomiao==99){xiaomiao=0;miao++;if(miao==60){miao=0;fen++;if(fen==99){fen=0;}}}}}}Screen.c:#include "reg52.h"#include "macroconst.h"#include "delay.h"#include "18b20.h"#include "atao_12864.h"#include "ds1302.h"#include "24c02.h"#include "festival.h"#include "keyscan.h"idata unsigned char miao=0,fen=78,xiaomiao=0,tt=0;idata unsigned char bai,shi,ge,shinian,genian,shiyue,geyue,shiri,geri,shishi,geshi,shifen,gefen,shimi ao,gemiao;idata unsigned char Number[4];unsigned char code mainmenu[]={" 主菜单""3.查询 4.温度""1.调时 2.秒表""5.设置 6.返回"};unsigned char code setmenu[]={" 设置""3.查温 4.按键""1.界面 2.闹铃""5.报时 6.返回"};void gettime(){shinian=(time_buf1[1]%100)/10;genian=(time_buf1[1]%100)%10;shiyue=(time_buf1[2])/10;geyue=(time_buf1[2])%10;shiri=(time_buf1[3])/10;geri=(time_buf1[3])%10;shishi=(time_buf1[4])/10;geshi=(time_buf1[4])%10;shifen=(time_buf1[5])/10;gefen=(time_buf1[5])%10;shimiao=(time_buf1[6])/10;gemiao=(time_buf1[6])%10;}void screen_select(uchar num){// initina1();gettime() ;if(num==1) //----------主界面{Lcd_Set_Post(1,0);TransferData(shinian+48,1);//----------------------年TransferData(genian+48,1);TransferData('/',1);TransferData(shiyue+48,1);//----------------------月TransferData(geyue+48,1);TransferData('/',1);TransferData(shiri+48,1);//----------------------日TransferData(geri+48,1);Lcd_Set_Post(1,4);if(state[1]==1)//----------------闹铃的状态图标{TransferData(' ',1);TransferData(14,1);}Lcd_Set_Post(1,5);if(key_sound==1){TransferData(13,1);}if(state[0]==0){Lcd_Set_Post(1,7); //----------------农历年nian(0);Lcd_Set_Post(2,0);//----------------------- 农历日月LCD_WRITE_CHAR("农历");Conversion(0,time_buf[1],time_buf[2],time_buf[3]);TransferData(month_moon/16+'0',1);TransferData(month_moon%16+'0',1);TransferData('/',1);TransferData(day_moon/16+'0',1);TransferData(day_moon%16+'0',1);}if(state[0]==1){Lcd_Set_Post(3,5);}else {Lcd_Set_Post(2,5);}LCD_WRITE_CHAR("星期");//----------------------星期if(time_buf1[7]==7) {LCD_WRITE_CHAR("日");}if(time_buf1[7]==6) {LCD_WRITE_CHAR("六");}if(time_buf1[7]==5) {LCD_WRITE_CHAR("五");}if(time_buf1[7]==4) {LCD_WRITE_CHAR("四");}if(time_buf1[7]==3) {LCD_WRITE_CHAR("三");}if(time_buf1[7]==2) {LCD_WRITE_CHAR("二");}if(time_buf1[7]==1) {LCD_WRITE_CHAR("一");}Lcd_Set_Post(3,0);TransferData(shishi+48,1);//----------------------时TransferData(geshi+48,1);TransferData(58,1);TransferData(shifen+48,1);//----------------------分TransferData(gefen+48,1);TransferData(58,1);TransferData(shimiao+48,1);//----------------------秒TransferData(gemiao+48,1);if(state[0]==0){bai=(temph/100); //---------------------------------温度shi=(temph%100)/10;ge=(temph%100)%10;Lcd_Set_Post(3,4);if(zerotemp==0){TransferData(' ',1);TransferData(' ',1);} Lcd_Set_Post(3,5);TransferData(shi+48,1);TransferData(ge+48,1);TransferData('.',1);TransferData(templ+48,1);TransferData(0xa1,1);TransferData(0xe6,1);Lcd_Set_Post(4,0);festival(time_buf[2],time_buf[3],time_buf[4]);//农历}}if(num==3)//----------主菜单{Lcd_Set_Post(1,0);//--------设置显示位置LCD_WRITE_CHAR(mainmenu);}if(num==4)//----------设置菜单{Lcd_Set_Post(1,0);//--------设置显示位置LCD_WRITE_CHAR(setmenu);}if(num==5)//----------时间设置{Lcd_Set_Post(1,2);//--------设置显示位置LCD_WRITE_CHAR("时间设置");Lcd_Set_Post(2,1);TransferData(shinian+48,1);//----------------------年TransferData(genian+48,1);LCD_WRITE_CHAR("年");TransferData(shiyue+48,1);//----------------------月TransferData(geyue+48,1);LCD_WRITE_CHAR("月");TransferData(shiri+48,1);//----------------------日TransferData(geri+48,1);LCD_WRITE_CHAR("日");TransferData(time_buf1[7]+48,1);//---------------星期Lcd_Set_Post(3,2);TransferData(shishi+48,1);//--------------------时TransferData(geshi+48,1);LCD_WRITE_CHAR("时");TransferData(shifen+48,1);//---------------------分TransferData(gefen+48,1);LCD_WRITE_CHAR("分");TransferData(shimiao+48,1);//--------------------秒TransferData(gemiao+48,1);}if(num==6)//----------秒表{uchar shi1,shi2,shi3,ge1,ge2,ge3;Lcd_Set_Post(1,3);//--------设置显示位置LCD_WRITE_CHAR("秒表");Lcd_Set_Post(3,2);shi1=fen/10;ge1=fen%10;TransferData(shi1+48,1);TransferData(ge1+48,1);TransferData(':',1);shi2=miao/10;ge2=miao%10;TransferData(shi2+48,1);TransferData(ge2+48,1);TransferData(':',1);shi3=xiaomiao/10;ge3=xiaomiao%10;TransferData(shi3+48,1);TransferData(ge3+48,1);}if(num==8){Lcd_Set_Post(1,2);//--------农历查询LCD_WRITE_CHAR("温度查询");Lcd_Set_Post(3,0);//--------农历查询LCD_WRITE_CHAR("最高温度"); TransferData(':',1);RdFromROM(Number,0,4);if(Number[3]==0){TransferData('-',1);}Lcd_Set_Post(3,5);TransferData(Number[0]+48,1); TransferData(Number[1]+48,1); TransferData('.',1);TransferData(Number[2]+48,1); TransferData(0xa1,1);TransferData(0xe6,1); Lcd_Set_Post(4,0);//--------农历查询LCD_WRITE_CHAR("最低温度"); TransferData(':',1);RdFromROM(Number,4,4);if(Number[3]==0){TransferData('-',1);}Lcd_Set_Post(4,5);TransferData(Number[0]+48,1); TransferData(Number[1]+48,1); TransferData('.',1);TransferData(Number[2]+48,1); TransferData(0xa1,1);TransferData(0xe6,1); }if(num==9)//----------界面菜单{Lcd_Set_Post(1,2);//--------设置显示位置LCD_WRITE_CHAR("界面选择");Lcd_Set_Post(2,0);TransferData(1+48,1);TransferData('.',1);LCD_WRITE_CHAR("多功能界面");Lcd_Set_Post(3,0);TransferData(2+48,1);TransferData('.',1);LCD_WRITE_CHAR("简洁界面");}。

12864液晶屏(带字库)51单片机3线串口驱动程序

12864液晶屏(带字库)51单片机3线串口驱动程序

#include<reg51.h>typedef unsigned char uint8; typedef unsigned int uint16; typedef unsigned long uitn32;sbit CS = P1^0;//片选信号引脚sbit SDA = P1^1;//数据线sbit SCK = P1^2;//串行时钟线//sbit RST = P1^3;//复位引脚//sbit PSB = P1^4;//串并控制引脚code uint8 strint1[] = "I Love You !";/*void delay5ms(void) //误差0us {unsigned char a,b;for(b=185;b>0;b--)for(a=12;a>0;a--);}*///发送一个字节void Send_Byte(uint8 dat){uint8 i;SCK = 0;for(i=0;i<8;i++){SDA = dat&0x80;SCK = 1;dat <<= 1;SCK = 0;}}//读取一个字节数据uint8 Read_Byte(void){uint8 i;uint16 byte = 0;SCK = 0;for(i=0;i<16;i++){byte <<= 1;SCK = 1;if(SDA)byte |= 0x0001;SCK = 0;}byte = ((byte>>4)|(byte>>8))&0x00ff;return ((uint8)(byte));}//读忙标志void Read_Busy(void){uint8 temp;CS = 1;do{Send_Byte(0xfc);//发送读命令temp = Read_Byte();//读取数据}while(temp&0x80);CS = 0;}//发送命令void Write_Cmd(uint8 cmd){uint8 temph = 0;uint8 templ = 0;//制作发送命令格式temph = cmd & 0xf0;templ = (cmd & 0x0f) << 4;Read_Busy();CS = 1;Send_Byte(0XF8);//发送命令命令//发送命令Send_Byte(temph);Send_Byte(templ);CS = 0;}//发送数据void Write_Dat(uint8 dat){uint8 temph = 0;uint8 templ = 0;//制作发送数据格式temph = dat & 0xf0;templ = (dat & 0x0f) << 4;Read_Busy();CS = 1;Send_Byte(0XFA);//发送数据命令Send_Byte(temph);//发送数据Send_Byte(templ);CS = 0;}//在指定位置显示半字宽字符void Dis_HCGROM(uint8 x,uint8 y,uint8 dat) {uint8 addr;switch(y){case 0:addr = 0x80 + x;break;case 1:addr = 0x90 + x;break;case 2:addr = 0x88 + x;break;case 3:addr = 0x98 + x;break;default:break;}Write_Cmd(addr);Write_Dat(dat);}//指定位置显示字符串void Dis_String(uint8 x, uint8 y, uint8 len, uint8 *dat) {uint8 addr,i;switch(y){case 0:addr = 0x80 + x;break;case 1:addr = 0x90 + x;break;case 2:addr = 0x88 + x;break;case 3:addr = 0x98 + x;break;default:break;}Write_Cmd(addr);for(i = 0;i < len;i++){Write_Dat(*dat++);}}//制定位置显示8位无符号数字void Dis_UNum8(uint8 x,uint8 y,uint8 dat){uint8 addr;switch(y){case 0:addr = 0x80 + x;break;case 1:addr = 0x90 + x;break;case 2:addr = 0x88 + x;break;case 3:addr = 0x98 + x;break;default:break;}Write_Cmd(addr);Write_Dat(dat/100%10+'0');Write_Dat(dat/10%10+'0');Write_Dat(dat/1%10+'0');}//制定位置显示16位无符号数字void Dis_UNum16(uint8 x,uint8 y,uint8 dat) {uint8 addr;switch(y){case 0:addr = 0x80 + x;break;case 1:addr = 0x90 + x;break;case 2:addr = 0x88 + x;break;case 3:addr = 0x98 + x;break;default:break;}Write_Cmd(addr);Write_Dat(dat/10000%10+'0');Write_Dat(dat/1000%10+'0');Write_Dat(dat/100%10+'0');Write_Dat(dat/10%10+'0');Write_Dat(dat/1%10+'0');}//在指定位置显示汉字//x范围:0-7,y范围:0-3//dat:汉字字形码void Dis_GB(uint8 x,uint8 y,uint16 dat) {uint8 addr;switch(y){case 0:addr = 0x80 + x;break;case 1:addr = 0x90 + x;break;case 2:addr = 0x88 + x;break;case 3:addr = 0x98 + x;break;default:break;}Write_Cmd(addr);Write_Dat((uint8)(dat >> 8));Write_Dat((uint8)(dat));}//LCD初始化void LCD_Init(void){/*RST = 0;delay5ms();delay5ms();RST = 1;PSB = 0;*/Write_Cmd(0X30);Write_Cmd(0X01);Write_Cmd(0X02);Write_Cmd(0X0C);}void main(void){LCD_Init();while(1){Dis_GB(0,0,0xc9b5);Dis_HCGROM(1,0,0x03);Dis_String(0,1,13,strint1);Dis_UNum8(0,2,250);} }。

51C语言程序集合 LCD12864

51C语言程序集合 LCD12864
i_data=temp_data1|temp_data2;
i_data&=0xf0;
for(i=0;i<8;i++)
{
LCD_SID=(bit)(i_data&0x80);
LCD_SCLK=0;
LCD_SCLK=1;
i_data=i_data<<1;
}
LCD_CS=0;
}
void lcd_init()
{
uchar command_data;
delay1ms(100);
command_data=0x30; /*功能设置:一次送8位数据,基本指令集*/
send_command(command_data);
send_command(0x01);
uint t=0;
lcd_init();
for(i=0;i<2;i++)
{ LCD_Y=0x80;
for(j=0;j<32;j++)
{ paintaddr(LCD_X,LCD_Y);
for(k=0;k<16;k++)
{ send_da(*(p+t));
t++;
LCD_SCLK=0;
LCD_SCLK=1;
i_data=i_data<<1;
}
i_data=command_data;
i_data&=0xf0;
for(i=0;i<8;i++)
{
LCD_SID=(bit)(i_data&0x80);

51单片机驱动显示屏12864

51单片机驱动显示屏12864
0x00,0x80,0x60,0x1F,0x02,0x02,0x02,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: 机 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x10,0xD0,0xFF,0x90,0x10,0x00,0xFE,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,
0x04,0x03,0x00,0xFF,0x00,0x11,0x08,0x04,0x03,0x00,0xFF,0x00,0x03,0x04,0x08,0x00,
/*-- 文字: 辉 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x44,0x58,0xC0,0x7F,0xD0,0x48,0x26,0x22,0xE2,0x3A,0xA2,0x22,0x22,0x2A,0x06,0x00,
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,
/*-- 文字: --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
uchar code hz[]={
/*-- 文字: 邓 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x12,0x22,0x42,0x82,0x62,0x1E,0x00,0x00,0xFE,0x02,0x22,0xDA,0x06,0x00,0x00,

12864程序(51总线方式)

12864程序(51总线方式)

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

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

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

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

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

/*************************************** 控制器:KS0108* MCU:AT89C5* ,晶体频率:12MHz* 取模方式:纵向字节倒序* CS1和CS2为低电平有效**************************************/#include <reg52.h>#define uchar unsigned char#define uint unsigned int#define LCD_PORT P0#define Left 1#define Right 2sbit LCD_Busy=P0^7;sbit LCD_EN = P1^2;sbit LCD_RS = P1^0;sbit LCD_RW = P1^1;sbit LCD_RST= P1^7;sbit LCD_CS2= P3^6;sbit LCD_CS1= P3^5;uchar DisBuf[32],Page_Num,Clm_Num;code char Table0[]={/*-- 文字: A --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27 ,0x38,0x20,/*-- 文字: B --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11 ,0x0E,0x00,/*-- 文字: C --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10 ,0x08,0x00,/*-- 文字: D --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10 ,0x0F,0x00,/*-- 文字: E --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20 ,0x18,0x00,/*-- 文字: F --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00 ,0x00,0x00,/*-- 文字: G --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E ,0x02,0x00,};code unsigned char Table3[]={/*-- 文字: 天 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x40,0x42,0x42,0x42,0x42,0x42,0xFE,0x42,0x42,0x42,0x42,0x42,0x42 ,0x40,0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x06,0x01,0x02,0x04,0x08,0x10,0x30,0x60 ,0x20,0x00,/*-- 文字: 仙 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x80,0x60,0xF8,0x07,0x02,0xE0,0x00,0x00,0x00,0xFF,0x00,0x00,0x00 ,0xE0,0x00,0x01,0x00,0x00,0x7F,0x00,0x20,0x7F,0x20,0x20,0x20,0x3F,0x20,0x20,0x20 ,0x7F,0x00,/*-- 文字: 妹 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x08,0x88,0x7F,0x0A,0x08,0xF8,0x80,0x88,0x88,0x88,0xFF,0x88,0x88,0x88 ,0x80,0x00,0x40,0x21,0x12,0x0C,0x3A,0x11,0x40,0x30,0x0C,0x03,0xFF,0x06,0x08,0x30 ,0x10,0x00,/*-- 文字: 妹 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x08,0x88,0x7F,0x0A,0x08,0xF8,0x80,0x88,0x88,0x88,0xFF,0x88,0x88,0x88 ,0x80,0x00,0x40,0x21,0x12,0x0C,0x3A,0x11,0x40,0x30,0x0C,0x03,0xFF,0x06,0x08,0x30 ,0x10,0x00};code unsigned char Table4[]={/*-- 文字: 我 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x20,0x20,0x22,0x22,0xFE,0x21,0x21,0x20,0x20,0xFF,0x20,0x22,0xAC,0x20 ,0x20,0x00,0x04,0x04,0x42,0x82,0x7F,0x01,0x01,0x10,0x10,0x08,0x07,0x1A,0x21,0x40 ,0xF0,0x00,/*-- 文字: 好 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x10,0xF0,0x1F,0x10,0xF0,0x80,0x82,0x82,0x82,0xF2,0x8A,0x86,0x82 ,0x80,0x00,0x80,0x43,0x22,0x14,0x0C,0x73,0x20,0x00,0x40,0x80,0x7F,0x00,0x00,0x00 ,0x00,0x00,/*-- 文字: 想 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x08,0xC8,0x38,0xFF,0x18,0x68,0x08,0x00,0xFE,0x2A,0x2A,0x2A,0x2A,0xFE ,0x00,0x00,0x01,0x40,0x70,0x01,0x38,0x40,0x40,0x44,0x59,0x41,0x41,0x61,0x01,0x09 ,0x30,0x00,/*-- 文字: 你 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x80,0x40,0xF0,0x2C,0x43,0x20,0x98,0x0F,0x0A,0xE8,0x08,0x88,0x28,0x1C ,0x08,0x00,0x00,0x00,0x7F,0x00,0x10,0x0C,0x03,0x21,0x40,0x3F,0x00,0x00,0x03,0x1C ,0x08,0x00};code unsigned char Table5[]={/*-- 调入了一幅图像:C:\Documents and Settings\sammy\桌面\小新.bmp --*//*-- 宽度x高度=64x64 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0xF0 ,0xF8,0x7C,0x3C,0x1E,0x1E,0x8F,0xCF,0xCF,0xCF,0xDF,0x9F,0x9F,0x1F,0x1F,0x3F,0x3E ,0x3E,0x3E,0x7C,0x7C,0x7C,0xF8,0xF8,0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x20,0x10,0x08,0x08,0x1E,0x3F,0x7F,0x03 ,0x00,0x00,0x00,0x06,0x07,0x07,0x03,0x03,0x03,0x0F,0x3F,0x3F,0x7E,0x78,0x78,0x30 ,0x00,0x00,0x00,0x00,0x60,0xE0,0xF0,0x78,0x39,0x39,0x73,0xFE,0x60,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x03,0x04,0x08,0x11,0x08,0x04,0x83,0x80,0x0C,0x92,0xA2,0x44 ,0x22,0x12,0x00,0x00,0x00,0x00,0x00,0x0F,0x30,0x40,0x80,0x80,0x80,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x02,0x02,0x04,0x04,0x04,0x08,0x08,0x08,0x08,0x10,0x10,0x00 ,0x00,0x00,0x00,0x40,0x40,0x80,0x80,0x80,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00 ,0x00,0x60,0x90,0x10,0x20,0x10,0x90,0x60,0x00,0x03,0x04,0x08,0x11,0x08,0x04,0x03 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0C,0x10 ,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x01,0x06,0xF8,0x00,0x00 ,0x00,0x00,0x00,0x01,0x02,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F ,0x7F,0xFF,0xF3,0xF3,0xFE,0xFC,0xFC,0xF8,0xF8,0xF0,0xF0,0xF0,0xE0,0xE0,0xE0,0xE0 ,0xE0,0xE0,0xE4,0xE0,0xE0,0xE0,0x10,0x10,0x10,0x08,0x08,0x04,0x02,0x01,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xD8,0xD8,0xFC ,0xFC,0xFC,0xFD,0xFD,0xFF,0xF7,0xF7,0xF7,0xF7,0xFF,0xFF,0xFF,0xFF,0xF3,0xF7,0xF7 ,0xFF,0xFF,0xFF,0xFD,0xFD,0xFC,0xDC,0xD8,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0 ,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0 ,0xC0,0xC0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF ,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF ,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF ,0xFF,0xFF};code uchar Table8[]={/*-- 文字: 相 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x10,0xD0,0xFF,0x30,0x50,0x90,0x00,0xFE,0x22,0x22,0x22,0x22,0xFE ,0x00,0x00,0x04,0x03,0x00,0xFF,0x00,0x00,0x01,0x00,0xFF,0x42,0x42,0x42,0x42,0xFF ,0x00,0x00,/*-- 文字: 约 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x40,0x60,0x58,0xC7,0x60,0x18,0x40,0x20,0x58,0x8F,0x08,0x08,0x08,0xF8 ,0x00,0x00,0x10,0x32,0x13,0x12,0x0A,0x0A,0x08,0x00,0x00,0x00,0x43,0x80,0x40,0x3F ,0x00,0x00,/*-- 文字: 丛 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0xFE,0x80,0x00,0x00,0x00 ,0x00,0x00,0x20,0x30,0x2C,0x23,0x20,0x21,0x36,0x2C,0x23,0x20,0x20,0x23,0x26,0x3C ,0x28,0x00,/*-- 文字: 林 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x10,0x90,0xFF,0x90,0x10,0x00,0x10,0x10,0xD0,0xFF,0x90,0x10,0x10 ,0x10,0x00,0x08,0x06,0x01,0xFF,0x00,0x13,0x08,0x04,0x03,0x00,0xFF,0x01,0x06,0x18 ,0x08,0x00};code uchar Table9[]={/*-- 文字: 浪 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x08,0x30,0x01,0xC6,0x30,0x00,0xFC,0x94,0x95,0x96,0x94,0x94,0xFC,0x00 ,0x00,0x00,0x04,0x04,0xFE,0x01,0x00,0x00,0xFF,0x40,0x21,0x06,0x08,0x34,0x62,0xC2 ,0x40,0x00,/*-- 文字: 漫 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x20,0x81,0x66,0x00,0xC0,0x5F,0xD5,0x55,0x55,0xD5,0x55,0x5F,0xC0 ,0x00,0x00,0x04,0xFC,0x03,0x00,0x00,0x81,0x85,0x4D,0x55,0x25,0x35,0x4D,0xC5,0x41 ,0x00,0x00,/*-- 文字: 野 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x7E,0x4A,0xFE,0x4A,0x4A,0x7E,0x00,0x42,0x52,0xD2,0x6A,0x46,0xC2 ,0x40,0x00,0x22,0x22,0x22,0x1F,0x12,0x12,0x12,0x00,0x40,0x80,0x7F,0x00,0x00,0x00 ,0x00,0x00,/*-- 文字: 岭 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0xF0,0x00,0xFF,0x00,0xF0,0x40,0x20,0x10,0x2C,0x43,0x04,0x08,0x70 ,0x20,0x00,0x08,0x1F,0x08,0x07,0x04,0x07,0x01,0x05,0x09,0x11,0x29,0x65,0x03,0x01 ,0x00,0x00};void Delay_us(unsigned int DelayTime){while(DelayTime) DelayTime--;}void Delay_x10ms(unsigned char DelayTime) //***************10ms延时**********//{unsigned char i,j,k;for(i=0;i<DelayTime;i++)for(j=0;j<10;j++)for(k=0;k<120;k++) {;}}/*----------------------------------------------------------------------------下面这个函数用于液晶模块的忙信号检测。

51单片机串行12864显示.c

51单片机串行12864显示.c
void Main()
{
CH = 0;
delay(1);
lcdinit();
delay(10);
while(1)
{
Test();
delay(5000);
}
}
* 名称 : write_com()
* 功能 : 写串口指令
* 输入 : cmdcode
* 输出 : 无
***********************************************************************/
void write_com(unsigned char cmdcode)
* 输入 : t
* 输出 : 无
***********************************************************************/
void delay(unsigned int t)
{
unsigned int i,j;
for(i=0; i<t; i++)
* 名称 : hzkdis()
* 功能 : 显示字符串
* 输入 : *s
* 输出 : 无
***********************************************************************/
void hzkdis(unsigned char code *s)
* 名称 : lcdinit()
* 功能 : 初始化函数
* 输入 : cmdcode
* 输出 : 无
***********************************************************************/

基于51单片机的12864液晶画点程序

基于51单片机的12864液晶画点程序
{
unsigned char largex,largey,smallx,smally; //将两点横纵坐标按大小存储
unsigned char i;
if(x1 > x2)
{
largex = x1;
smallx = x2;
}
else
{
largex = x2;
smallx = x1;
}
if(y1 > y2)
}else{
DL |= (0x01 << (7 - (k % 8))); //修改该点同时保持其他位不变
}
break;
case 2:
if(k < 8){
DH ^= (0x01 << (7 - k)); //修改该点同时保持其他位不变
}else{
DL ^= (0x01 << (7 - (k % 8))); //修改该点同时保持其他位不变
DH &= ~(0x01 << (7 - k)); //修改该点同时保持其他位不变
}else{ //点在低字节
DL &= ~(0x01 << (7 - (k % 8))); //修改该点同时保持其他位不变
}
break;
case 1:
if(k < 8){
DH |= (0x01 << (7 - k)); //修改该点同时保持其他位不变
com(0x34); //在写GDRAM的地址之前一定要打开扩充指令集
//否则地址写不进去!!
for( j = 0 ; j < 32 ; j++ )
{
com(0x80 + j) ; //写Y坐标

51单片机+12864程序

51单片机+12864程序

#include<reg52.h>#include"zifuku.h"#define uchar unsigned char#define uint unsigned intsbit di =P2^0; //指令sbit rw =P2^1; // Write or Read,Hread,Lwrite sbit e =P2^2; // 读写使能sbit cs1=P2^3 // cs1=L,选择左边屏sbit rst=P2^6;// Lcm reset,低有效sbit cs2=P2^4; //cs2=L,选择中间屏sbit cs3=P2^5; // cs3=L,选择右边屏sbit bf =P1^7;sbit res=P1^4;void delay(uint us){while(us--);}void delay1(uint ms){uint i,j;for(i=0;i<ms;i++)for(j=0;j<1000;j++);}void write_com(uchar comm){rw=0;di=0;e=1;P1=comm;e=0;}void write_date(uchar dat){rw=0;di=1;e=1;P1=dat;e=0;}void lat_disp(uchar date1,uchar date2){uchar i,j;cs1=1;cs2=1;write_com(0x3f);for(j=0;j<8;j++){write_com(0xb8+j);write_com(0xc0);write_com(0x40);for(i=0;i<32;i++){write_date(date1);write_date(date2);}}}void vshowcustomrow(uchar ucpage,uchar ucline,uchar width,uchar *uca) {uchar count;if(ucline<64){cs1=1;cs2=0;write_com(0x3f);write_com(0xb8+ucpage);write_com(0xc0);write_com(0x40+ucline);{for(count=0;count<width;count++) write_date(*(uca+count));}}else{cs1=0;cs2=1;write_com(0x3f);write_com(0xb8+ucpage);write_com(0x40);write_com(0x40+ucline-64);for(count=0;count<width;count++) write_date(*(uca+count));}}void vshowonechin(uchar ucpage,uchar ucline,uchar *uca){vshowcustomrow(ucpage,ucline ,16,uca);vshowcustomrow(ucpage+1,ucline,16,uca+16);}void vshowonechar(uchar ucpage,uchar ucline,uchar *uca){vshowcustomrow(ucpage,ucline,8,uca);vshowcustomrow(ucpage+1,ucline,8,uca+8);}void vshowgraph(uchar ucpage,uchar ucline,uchar width,uchar high,uchar *uca) {uchar count;for(count=0;count<high;count++){vshowcustomrow(ucpage+count,ucline,width,uca+count*width);}}/*---------------显示1-----------------*/void disp1 (void){lat_disp(0x00,0x00);vshowonechin(0,0,uca_xiao);vshowonechin(0,16,uca_yun);vshowonechin(0,32,uca_ke);vshowonechin(0,48,uca_ji);vshowonechin(0,64,uca_you);vshowonechin(0,80,uca_xian);vshowonechin(0,96,uca_gong);vshowonechin(0,112,uca_si);vshowonechin(2,0,uca_xiao);vshowonechin(2,16,uca_yun);vshowonechin(2,32,uca_pai);vshowonechin(2,48,uca_ye); vshowonechin(2,64,uca_jing); vshowonechin(2,80,uca_xian1); vshowonechin(2,96,uca_shi); vshowonechin(2,112,uca_ping);vshowonechin(4,16,uca_huan); vshowonechin(4,32,uca_ying); vshowonechin(4,48,uca_ni); vshowonechin(4,64,uca_de); vshowonechin(4,80,uca_jia); vshowonechin(4,96,uca_meng);vshowonechar(6,0,uca_T); vshowonechar(6,8,uca_E); vshowonechar(6,16,uca_L); vshowonechar(6,24,uca_maohao);vshowonechar(6,32,uca_yi); vshowonechar(6,40,uca_san); vshowonechar(6,48,uca_qiu); vshowonechar(6,56,uca_er); vshowonechar(6,64,uca_zero); vshowonechar(6,72,uca_er); vshowonechar(6,80,uca_qiu); vshowonechar(6,88,uca_yi); vshowonechar(6,96,uca_ba); vshowonechar(6,104,uca_ba); vshowonechar(6,112,uca_er);}void disp2(void){ lat_disp(0x00,0x00); vshowgraph(2,32,32,4,uca_Pig); }void lcd_initilize(void){rst=0;delay(50);rst=1;write_com(0x3e);write_com(0x3f);}void main(){lcd_initilize();while(1){disp1();delay1(400);lat_disp(0xff,0x00);delay1(400);disp2();delay1(400);}}#include<reg52.h>unsigned char code uca_xiao[]={/*-- 文字: 小--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x00,0xC0,0x70,0x20,0x00,0xFF,0x00,0x10,0x20,0xC0,0x80,0x00,0x00,0x00, 0x04,0x02,0x01,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x01,0x07,0x02,0x00, };unsigned char code uca_yun[]={/*-- 文字: 芸--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x04,0x04,0x24,0x24,0x3F,0x24,0x24,0x24,0x24,0x3F,0x24,0x24,0x04,0x04,0x00, 0x01,0x01,0x41,0x61,0x51,0x49,0x47,0x65,0x21,0x21,0x25,0x29,0x71,0x21,0x01,0x00,};unsigned char code uca_ke[]={/*-- 文字: 科--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x12,0x92,0x72,0xFE,0x51,0x91,0x00,0x22,0xCC,0x00,0x00,0xFF,0x00,0x00,0x00, 0x04,0x02,0x01,0x00,0xFF,0x00,0x04,0x04,0x04,0x02,0x02,0x02,0xFF,0x01,0x01,0x00, };unsigned char code uca_ji[]={/*-- 文字: 技--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x08,0x08,0x88,0xFF,0x48,0x28,0x00,0xC8,0x48,0x48,0x7F,0x48,0xC8,0x48,0x08,0x00,0x01,0x41,0x80,0x7F,0x00,0x40,0x40,0x20,0x13,0x0C,0x0C,0x12,0x21,0x60,0x20,0x00, };unsigned char code uca_you[]={/*-- 文字: 有--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x04,0x84,0x44,0xE4,0x34,0x2C,0x27,0x24,0x24,0x24,0xE4,0x04,0x04,0x04,0x00,0x02,0x01,0x00,0x00,0xFF,0x09,0x09,0x09,0x29,0x49,0xC9,0x7F,0x00,0x00,0x00,0x00, };unsigned char code uca_xian[]={/*-- 文字: 限--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0xFE,0x02,0x32,0x4E,0x82,0x00,0xFE,0x4A,0xCA,0x4A,0x4A,0x4A,0x7E,0x00,0x00,0x00, 0xFF,0x00,0x02,0x04,0x03,0x00,0xFF,0x40,0x20,0x03,0x0C,0x12,0x21,0x60,0x20,0x00, };unsigned char code uca_gong[]={/*-- 文字: 公--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x80,0x40,0x30,0x0E,0x84,0x00,0x00,0x0E,0x10,0x60,0xC0,0x80,0x80,0x00,0x00,0x01,0x20,0x70,0x28,0x24,0x23,0x31,0x10,0x10,0x14,0x78,0x30,0x01,0x00,0x00, };unsigned char code uca_si[]={/*-- 文字: 司--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x10,0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x12,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x1F,0x04,0x04,0x04,0x04,0x04,0x04,0x0F,0x00,0x20,0x40,0x3F,0x00,0x00, };unsigned char code uca_da[]={/*-- 文字: 大--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x20,0x20,0x20,0x20,0x20,0x20,0xA0,0x7F,0xA0,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x01,0x06,0x08,0x30,0x60,0xC0,0x40,0x00, };unsigned char code uca_pai[]={/*-- 文字: 牌--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0xFE,0x90,0x90,0x9F,0x10,0x00,0xFE,0x92,0xD3,0xBE,0x92,0x92,0xFE,0x00,0x00, 0x40,0x3F,0x00,0x00,0x7F,0x04,0x04,0x06,0x05,0x04,0xFF,0x04,0x04,0x05,0x04,0x00, };unsigned char code uca_ye[]={/*-- 文字: 液--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x61,0x06,0xE0,0x18,0x84,0xE4,0x1C,0x84,0x65,0xBE,0x24,0xA4,0x64,0x04,0x00,0x04,0x04,0xFF,0x00,0x01,0x00,0xFF,0x41,0x21,0x12,0x0C,0x1B,0x61,0xC0,0x40,0x00, };unsigned char code uca_jing[]={/*-- 文字: 晶--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x00,0x00,0x7E,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x7E,0x00,0x00,0x00,0x00, 0x00,0x7F,0x25,0x25,0x25,0x25,0x7F,0x00,0x00,0x7F,0x25,0x25,0x25,0x25,0x7F,0x00, };unsigned char code uca_xian1[]={/*-- 文字: 显--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x00,0x3E,0x2A,0xEA,0x2A,0x2A,0x2A,0xEA,0x2A,0x3E,0x00,0x00,0x00,0x00, 0x20,0x21,0x22,0x2C,0x20,0x3F,0x20,0x20,0x20,0x3F,0x28,0x24,0x23,0x20,0x20,0x00, };unsigned char code uca_shi[]={/*-- 文字: 示--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x20,0x20,0x22,0x22,0x22,0x22,0xE2,0x22,0x22,0x22,0x22,0x22,0x20,0x20,0x00,0x10,0x08,0x04,0x03,0x00,0x40,0x80,0x7F,0x00,0x00,0x01,0x02,0x0C,0x18,0x00,0x00, };unsigned char code uca_ping[]={/*-- 文字: 屏--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0xFF,0x09,0x49,0x59,0xE9,0x49,0x49,0x49,0xE9,0x59,0x49,0x4F,0x00,0x00, 0x40,0x30,0x0F,0x82,0x42,0x32,0x0F,0x02,0x02,0x02,0xFF,0x02,0x02,0x02,0x02,0x00, };unsigned char code uca_huan[]={/*-- 文字: 欢--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x14,0x24,0x44,0x84,0x64,0x1C,0x20,0x18,0x0F,0xE8,0x08,0x08,0x28,0x18,0x08,0x00, 0x20,0x10,0x4C,0x43,0x43,0x2C,0x20,0x10,0x0C,0x03,0x06,0x18,0x30,0x60,0x20,0x00, };unsigned char code uca_ying[]={/*-- 文字: 迎--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x40,0x41,0xCE,0x04,0x00,0xFC,0x04,0x02,0x02,0xFC,0x04,0x04,0x04,0xFC,0x00,0x00, 0x40,0x20,0x1F,0x20,0x40,0x47,0x42,0x41,0x40,0x5F,0x40,0x42,0x44,0x43,0x40,0x00, };unsigned char code uca_ni[]={/*-- 文字: 你--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x80,0x40,0xF0,0x2C,0x43,0x20,0x98,0x0F,0x0A,0xE8,0x08,0x88,0x28,0x1C,0x08,0x00, 0x00,0x00,0x7F,0x00,0x10,0x0C,0x03,0x21,0x40,0x3F,0x00,0x00,0x03,0x1C,0x08,0x00, };unsigned char code uca_de[]={/*-- 文字: 的--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0xF8,0x8C,0x8B,0x88,0xF8,0x40,0x30,0x8F,0x08,0x08,0x08,0x08,0xF8,0x00,0x00, 0x00,0x7F,0x10,0x10,0x10,0x3F,0x00,0x00,0x00,0x03,0x26,0x40,0x20,0x1F,0x00,0x00, };unsigned char code uca_jia[]={/*-- 文字: 加--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x08,0x08,0x08,0xFF,0x08,0x08,0xF8,0x00,0xF8,0x08,0x08,0x08,0xF8,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x20,0x40,0x3F,0x00,0x7F,0x10,0x10,0x10,0x3F,0x00,0x00, };unsigned char code uca_meng[]={/*-- 文字: 盟--*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0xFE,0x92,0x92,0x92,0xFE,0x00,0x80,0x7E,0x2A,0x2A,0x2A,0x2A,0xFE,0x00,0x00, 0x40,0x40,0x7C,0x44,0x44,0x7C,0x46,0x45,0x44,0x7C,0x44,0x45,0x7E,0x41,0x40,0x00, };unsigned char code uca_T[]={/*-- 文字: T --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00, };unsigned char code uca_E[]={/*-- 文字: E --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00, };unsigned char code uca_L[]={/*-- 文字: L --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00, };unsigned char code uca_maohao[]={/*-- 文字: : --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00, };unsigned char code uca_zero[]={/*-- 文字: 0 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,};unsigned char code uca_yi[]={/*-- 文字: 1 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, };unsigned char code uca_er[]={/*-- 文字: 2 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00, };unsigned char code uca_san[]={/*-- 文字: 3 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00, };unsigned char code uca_s[]={/*-- 文字: 4 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00, };unsigned char code uca_wu[]={/*-- 文字: 5 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00, };unsigned char code uca_liu[]={/*-- 文字: 6 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00, };unsigned char code uca_qi[]={/*-- 文字: 7 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00, };unsigned char code uca_ba[]={/*-- 文字: 8 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00, };unsigned char code uca_qiu[]={/*-- 文字: 9 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00, };unsigned char code uca_Pig[]={0x00,0x80,0x40,0x30,0x08,0x04,0x82,0x81,0x61,0x01,0x12,0x8A,0x89,0x11,0x01,0x05, 0x13,0x09,0x89,0x91,0x01,0x31,0xC2,0x0A,0x04,0x02,0x02,0x02,0x02,0x1C,0xE0,0x00, 0x06,0x05,0xC4,0x32,0x0A,0x05,0x82,0x41,0x20,0x26,0x49,0x50,0x5C,0xAD,0xA6,0xA0, 0x86,0x49,0x50,0x5C,0x8D,0x06,0x80,0x41,0x02,0x02,0x04,0x0C,0x34,0xC8,0x09,0x0E, 0x00,0x00,0x03,0x0C,0x10,0x20,0x43,0x54,0xA8,0xD0,0x90,0x26,0x26,0x40,0x40,0x4C, 0x4C,0x20,0x20,0x90,0x4C,0x03,0x83,0x84,0x40,0x40,0x20,0x30,0x0C,0x03,0x00,0x00,0xE0,0xF0,0xF8,0xDC,0x8E,0x03,0x1F,0x21,0x5C,0xB4,0x34,0x1D,0x0D,0x06,0x0E,0x0E, 0x06,0x0D,0x1D,0x35,0x35,0x1D,0x80,0x40,0x21,0x1F,0x03,0x8E,0xDC,0xF8,0xF0,0xE0} ;//图片。

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。

12864的51程序

12864的51程序

#include <reg52.h>#define uchar unsigned char#define uint unsigned int/*****LCD接口定义*****/sbit SID = P1^1; //串行数据sbit SCLK = P1^2; //串行同步时钟sbit BSP=P1^3; //串并行选择端口,低电平选为串行发送数据/*****汉字地址表*****/uchar code add[]={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 table[]="努力奋斗,改变人生,实现人生梦想!" ;/*****n(ms)延时子程序*****/void delayms(uint t) //约延时n(ms){uint i;while(t--){for(i=0;i<125;i++);}}/*****串行发送一个字节*****/void send_byte(uchar byte){uchar i;for(i=0;i<8;i++){SCLK = 0;byte=byte<<1; //左移一位先发送高位的数据SID = CY; //移出的位给SIDSCLK = 1; //上升沿触发发送SCLK = 0;}}/*****写指令*****/void write_com(uchar com ){delayms(1);//检测忙的子程序我们就不写了,因为串行的不支持读操作,我们就用个延时吧send_byte(0xf8); //11111,RW(0),RS(0),0send_byte(0xf0&com); //高四位数据分两次发送,而且把数据放在高四位上发送send_byte(0xf0&com<<4); //低四位(先执行<<)}/*****写数据*****/void write_data(uchar date){delayms(1);send_byte(0xfa); //11111,RW(0),RS(1),0send_byte(0xf0&date); //高四位send_byte(0xf0&date<<4); //低四位(先执行<<)}/*****初始化LCD*****/void lcd_init(void){delayms(50); //等待时间要大于40毫秒给液晶一个准备的时间write_com(0x30); //选择基本指令集0x34选择扩充指令delayms(1);write_com(0x30); //选择8bit数据流DL=0/1:4/8位数据RE=1: 扩充指令操作RE=0: 基本指令操delayms(1);write_com(0x0c); //开显示(无游标、不反白)delayms(1);write_com(0x01); //清除显示,并且设定地址指针为00Hdelayms(30);}/*****显示汉字*****/void Chinese_disp(uchar x,uchar y,uchar code *s)//用上指针是非常方便的,调用时只要放个数组名即可{write_com(add[8*x+y]); //写地址x,y是用来确定起始地址的从零开始算起的while(*s!='\0') //空格的地址是0{if(y==8) //判断换行{ //若不判断,则自动从第一行到第三行y=0;x++;}if(x==4){x=0; //一屏显示完,回到屏左上角}write_com(add[8*x+y]);//更新地址一个地址要写完一个字,则要与两次数据写完write_data(*s); //写数据s++;write_data(*s); //写数据s++;y++; //写完一个字地址要往前走一位}}/*****主函数*****/void main(void){BSP=0;lcd_init();Chinese_disp(0,0,table);// 就是在第二行第一列显示"AAAAAA"while(1);}。

12864串口C51程序

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

液晶屏12864的51单片机程序

液晶屏12864的51单片机程序

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

12864的51c程序

12864的51c程序

#include<reg51.h>#include<absacc.h>#define uchar unsigned char#define datawr 0x1200 //写数据通道#define comwr 0x1000 //写控制命令通道#define datare 0x1300 //读数据通道#define comre 0x1100 //读忙通道uchar code disp_data[]={" 浙江大学" //第一行,第一页"04级通信工程一班" //第三行" 宁波理工学院" //第二行" 竞赛小组" //第四行"128X64液晶显示器" //第一行,第二页" 测试程序" //第三行" 07年07月25日" //第二行" Tornado "}; //第四行void set12864();void write_command(uchar command);void write_page(uchar data_add);void read_page(uchar data_add);void delays(uchar cont);void main(){while(1){set12864(); //初始化12864write_page(0); //写入一页数据read_page(0x30); //读出一页数据到内部RAMdelays(2); //延时2swrite_page(64); //写入下一页数据delays(2); //延时2s}}//初始化12864子程序void set12864(){write_command(0x30); //功能设定控制字write_command(0x0c); //显示开关控制字write_command(0x01); //清除屏幕控制字write_command(0x06); //进入设定点控制字}//写控制命令子程序void write_command(uchar command){bit flag="1"; //12864空闲标志位while(flag) //检查12864是否空闲flag="XBYTE"[comre]&0x80;XBYTE[comwr]=command; //空闲传送控制字}//写一页子程序void write_page(uchar data_add){bit flag="1"; //12864空闲标志位uchar num="64"; //64个循环,连续写入32个汉字或是64个西文字符write_command(0x80);for(;num>0;num--){while(flag) //检查12864是否空闲flag="XBYTE"[comre]&0x80;XBYTE[datawr]=disp_data[data_add++]; //空闲传送数据}}//读一页子程序void read_page(uchar data_add){bit flag="1"; //12864空闲标志位uchar num="64"; //64个循环,连续写入32个汉字或是64个西文字符write_command(0x80);for(;num>0;num--){while(flag) //检查12864是否空闲flag="XBYTE"[comre]&0x80;DBYTE[data_add++]=XBYTE[datare]; //空闲传送数据}}//延时cont秒子程序void delays(uchar count){unsigned char h,i,j,k;do{for(h=5;h>0;h--)for(i=4;i>0;i--)for(j=116;j>0;j--)for(k=214;k>0;k--);}while(--count);}这是图象显示程序:#include<reg51.h>#include<absacc.h>#define uchar unsigned char#define uint unsigned int#define datawr 0x1200 //写数据通道#define comwr 0x1000 //写控制命令通道#define datare 0x1300 //读数据通道#define comre 0x1100 //读忙通道uchar code disp_data[] = // 数据表{0x00,0x01,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00, 0x00,0x01,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00, 0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00, 0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00, 0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00, 0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00, 0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x80,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0xFF,0xFF,0xFF, 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x07,0xFF,0xFF, 0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x0B,0xFF, 0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x1F, 0x01,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00, 0x01,0xFF,0xFF,0xFF,0xF3,0x79,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00, 0x03,0xFF,0xFF,0xFF,0xE6,0x62,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE1,0x60,0x00,0x68, 0x01,0xFF,0xFF,0xFE,0x00,0x60,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE1,0x00,0x00,0x0E, 0x01,0xFF,0xFF,0xF8,0x00,0x4B,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x8E,0x08,0x79, 0x07,0xFF,0xFF,0xF0,0x00,0x41,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE6,0xC0,0x07,0x61,0xC3,0xFF,0xFE,0xC0,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xED,0xEF,0x3 F,0x83,0xFF,0xFE,0x60,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0xFF,0xFD,0xFC,0x6C,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF F,0xF0,0x7F,0xF3,0xFF,0xFE,0x60,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xF3,0xFF,0xFF,0x50,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC9,0xFB,0xFF,0xF1,0xF8,0x8C,0xD8,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFB,0x6F,0xD 9,0xC2,0x3F,0xF8,0x40,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xF6,0xDF,0x1E,0xFF,0xFF,0x7F,0xFC,0x38,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0x64,0x2F,0x6F,0xFF,0xFD,0x7B,0xFC,0x1F,0xE0,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0x5F,0x7C,0xEE,0xF F,0xC7,0xFF,0xBC,0x0F,0xFF,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xDF,0xFE,0xEF,0xF F,0xFF,0xE7,0xDC,0x07,0xE7,0xF8,0x12,0x7F,0xFF,0xFF,0xFF,0xFF,0x47,0xFF,0xFF,0xFF ,0xFF,0xE7,0x80,0x03,0xF4,0x00,0x00,0x5F,0xFF,0xFF,0xFE,0xFE,0xE3,0xFF,0xFF,0xFF ,0xFF,0xFE,0xC0,0x01,0xC0,0x00,0x00,0x1B,0xFF,0xFF,0xFB,0xFF,0xFF,0xFF,0xFF,0xF F,0x7F,0xEE,0xC0,0x00,0xC0,0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF ,0xFE,0x98,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xEF,0xFF,0xFF,0xFF,0xFF,0xFF, 0x20,0x0E,0x60,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x8F,0xFF,0xFF,0xFF,0xFF,0xFF, 0x05,0x80,0xE0,0x00,0x00,0x00,0x00,0x01,0xFF,0xFD,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0x09,0x80,0xA0,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0x85,0x2A,0xC0,0x00,0x00,0x00,0x00,0x01,0xFF,0xFB,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE ,0xBF,0xF3,0xC0,0x00,0x00,0x00,0x00,0x00,0xFF,0xF7,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8, 0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x01,0xFF,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0x00, 0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0xFF,0xC0,0xFF,0xFF,0xFF,0xFF,0xC0,0x1F, 0xFF,0xFF,0x80,0x00,0x40,0x00,0x00,0x00,0xFF,0x80,0xFF,0xFF,0xFF,0x80,0x07,0xFF, 0xFF,0xFF,0xC0,0x00,0xC0,0x00,0x00,0x01,0xFF,0x01,0xFF,0xFF,0xF8,0x00,0xFF,0xFF,0xFF,0xFF,0xE0,0x63,0x80,0x00,0x00,0x01,0xFE,0x01,0xFF,0x18,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x01,0xCC,0x01,0xFE,0x00,0x07,0xFF,0xFF,0xFF ,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x07,0xA0,0x03,0xFC,0x00,0xFF,0xFF,0xFF,0xFF ,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x05,0xC0,0x03,0xC8,0x00,0x7F,0xFF,0xFF,0xFF ,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x19,0x00,0x00,0x88,0x0C,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x0C,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0xC0,0x7F,0xFF,0xFF ,0xFF,0xFF,0xF8,0x07,0x0F,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x0F,0xFF,0xFE, 0xFF,0xFF,0xD0,0x07,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x03,0xFF,0xF8, 0xFF,0xFC,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xC0, 0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0xFF,0xF8, 0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x1F,0xFE, 0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x78,0x02,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF, 0xFF,0x00,0x00,0x00,0x00,0x00,0x03,0xF0,0x78,0x00,0x00,0x00,0x00,0x00,0x02,0xFF, 0xFE,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x7F, 0xF0,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x1F, 0xE0,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x1F, 0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x27, 0xC0,0x00,0x00,0x00,0x00,0x00,0x01,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x80,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01 };void set12864();void setxy(uchar x,uchar y);void write_command(uchar command);void write_16byte(uint data_add);void delays(uchar count);void main(){uchar x,y,i;while(1){y="0x80"; //设置液晶上半部分坐标x="0x80";delays(2); //延时2sset12864(); //初始化12864delays(2);for(i=0;i<32;i++) //写入液晶上半图象部分{ //写入坐标setxy(x,y);write_16byte(i*16); //连续写入16字节数据y++; //y轴地址加1}y="0x80"; //设置液晶下半部分坐标x="0x88";for(i=0;i<32;i++) //写入液晶下半图象部分{setxy(x,y); //写入坐标write_16byte((32+i)*16);//连续写入16字节数据y++; //y轴地址加1}write_command(0x34); //写入扩充指令命令write_command(0x36); //显示图象}}//初始化12864子程序void set12864(){write_command(0x30); //功能设定控制字write_command(0x0c); //显示开关控制字write_command(0x01); //清除屏幕控制字write_command(0x06); //进入设定点控制字}//设置绘图坐标void setxy(uchar x,uchar y){write_command(0x34); //写入扩充指令命令write_command(y); //写入y轴坐标write_command(x); //写入x轴坐标write_command(0x30); //写入基本指令命令}//写控制命令子程序void write_command(uchar command){bit flag="1"; //12864空闲标志位while(flag) //检查12864是否空闲flag="XBYTE"[comre]&0x80;XBYTE[comwr]=command; //空闲传送控制字}void write_16byte(uint data_add){bit flag="1"; //12864空闲标志位uchar num="16"; //16个循环,连续写入16个字节for(;num>0;num--){while(flag) //检查12864是否空闲flag="XBYTE"[comre]&0x80;XBYTE[datawr]=disp_data[data_add++]; //空闲传送数据}}//延时count秒子程序void delays(uchar count){unsigned char h,i,j,k;do{for(h=5;h>0;h--)for(i=4;i>0;i--)for(j=116;j>0;j--)for(k=214;k>0;k--);}while(--count);}回答者:liming19840827 - 四级2009-10-16 07:59#include <reg52.h>#define uint unsigned int#define uchar unsigned charsbit LCD_RS=P3^5;sbit LCD_RW=P3^6;sbit LCD_E=P3^4;sbit LCD_PSB=P3^7; //液晶有关控制位uchar code dis1[]={"一片枫叶"};/*=====================延时===========================*/void delay(uint z){uint x,y;for(x=z;x>0;x--)for(y=110;y>0;y--);}//写指令void write_com(uchar com){LCD_RS=0;LCD_RW=0;LCD_E=0;P0=com;delay(5);LCD_E=1;delay(5);LCD_E=0;}//写数据{void write_date(uchar date){LCD_RS=1;LCD_RW=0;LCD_E=0;P0=date;delay(5);LCD_E=1;delay(5);LCD_E=0;}//初始化液晶void chushi(){P0=0x7f;LCD_PSB=1;write_com(0x30);delay(5);write_com(0x0c);delay(5);write_com(0x01);delay(5);for(num=0;num<5;num++){write_date(dis1[num]);delay(20);}}}/*=======================主函数=========================*/ void main(){chushi();}回答者:ypfengye - 一级2009-10-19 21:15以下是源代码/*******************************main.h******************************/#ifndef _MAIN_H#define _MAIN_H#include <reg52.h>#define LcdDataPort P2 //数据端口#ifndef UCHAR_DEF#define UCHAR_DEFtypedef unsigned char uchar;#endifsbit Reset = P3^0; //复位sbit RS = P3^1; //指令数据选择sbit E = P3^2; //指令数据控制sbit CS1 = P3^4; //左屏幕选择,低电平有效sbit CS2 = P3^5; //右屏幕选择sbit RW = P3^3; //读写控制sbit busy = P2^7; //忙标志void SetOnOff(uchar onoff); //开关显示void SelectScreen(uchar screen);//选择屏幕void ClearScreen(uchar screen); //清屏void Show1616(uchar lin,uchar colum,uchar *address);//显示一个汉字void CheckState(); //判断状态void LcdDelay(unsigned int time); //延时void WriteData(uchar dat); //写数据void SendCommand(uchar command); //写指令void SetLine(uchar line); //置行地址void SetColum(uchar colum);//置列地址void SetStartLine(uchar startline);//置显示起始行void InitLcd(); //初始化void ResetLcd(); //复位#endif/*********************************************************************//***********************************lcd.c****************************************/#include "main.h"void CheckState(){E = 1;RS = 0;RW = 1;LcdDataPort = 0xff;while(!busy);}void LcdDelay(unsigned int time){while(time --);}void WriteData(uchar dat){CheckState();E = 1;RS = 1;RW = 0;LcdDataPort = dat;E = 0;}void SendCommand(uchar command){CheckState();E = 1;RW = 0;RS = 0;LcdDataPort = command;E = 0;}void SelectScreen(uchar screen) //0-全屏,1—左屏,2-右屏{switch(screen){case 0 :CS1 = 0;LcdDelay(2);CS2 = 1;LcdDelay(2);break;case 1 :CS1 = 1;LcdDelay(2);CS2 = 0;LcdDelay(2);break;case 2 :CS1 = 0;LcdDelay(2);CS2 = 0;LcdDelay(2);break;}}void ClearScreen(uchar screen) // screen 0-全屏,1—左屏,2-右屏{uchar i,j;SelectScreen(screen);for(i = 0;i < 8;i ++){SetLine(i);SetColum(0);for(j = 0;j < 64; j ++)WriteData(0);}}void SetLine(uchar line) //line -> 0 : 7{line = line & 0x07;line = line | 0xb8; //1011 1xxxSendCommand(line);}void SetColum(uchar colum) //colum -> 0 :63{colum = colum & 0x3f;colum = colum | 0x40; //01xx xxxxSendCommand(colum);}void SetStartLine(uchar startline) //startline -> 0 : 63{startline = startline & 0x3f;startline = startline | 0xc0; //11xxxxxxSendCommand(startline);}void SetOnOff(uchar onoff) //1-开显示0-关{if(onoff == 1)SendCommand(0x3f); //0011 111xelseSendCommand(0x3e);}void ResetLcd(){Reset = 0;LcdDelay(2);Reset = 1;LcdDelay(2);RS0 = 0;LcdDelay(2);RS1 = 0;LcdDelay(2);SetOnOff(1);}void InitLcd(){ResetLcd();SetOnOff(0);ClearScreen(2);SetLine(0);SetColum(0);SetStartLine(0);SetOnOff(1);}void Show1616(uchar lin,uchar colum,uchar *address){uchar i;SetLine(lin);SetColum(colum);for(i = 0;i < 16;i ++)WriteData(*(address ++));SetLine(lin + 1);SetColum(colum);for(i = 0;i < 16;i ++)WriteData(*(address ++));}/*******************************************************************************//********************************main.c***********************************************/ #include <reg52.h>#include "main.h"const uchar code HZ_tab[] = {0x10,0x21,0x62,0x06,0x82,0xE2,0x22,0x22,0x22,0xF2,0x22,0x02,0xFE,0x03,0x02,0x00, //河0x04,0x04,0xFE,0x01,0x00,0x0F,0x04,0x04,0x04,0x0F,0x40,0x80,0x7F,0x00,0x00,0x00,0x04,0xE4,0x24,0x24,0x64,0xA4,0x24,0x3F,0x24,0xA4,0x64,0x24,0x24,0xF6,0x24,0x00, //南0x00,0xFF,0x00,0x09,0x09,0x09,0x09,0x7F,0x09,0x09,0x09,0x49,0x80,0x7F,0x00,0x00,0x24,0x24,0x24,0xA4,0xFE,0xA3,0x22,0x00,0x24,0x48,0x00,0xFF,0x00,0x80,0x00,0x00, //科0x10,0x08,0x06,0x01,0xFF,0x00,0x01,0x02,0x02,0x02,0x02,0xFF,0x01,0x01,0x01,0x00,0x10,0x10,0x10,0xFF,0x10,0x10,0x88,0x88,0x88,0xFF,0x88,0x88,0x8C,0x08,0x00,0x00, //技0x04,0x44,0x82,0x7F,0x01,0x80,0x81,0x46,0x28,0x10,0x28,0x26,0x41,0xC0,0x40,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0xA0,0x7F,0xA0,0x20,0x20,0x20,0x20,0x30,0x20,0x00, //大0x00,0x40,0x40,0x20,0x10,0x0C,0x03,0x00,0x01,0x06,0x08,0x10,0x20,0x60,0x20,0x00,0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,0x90,0x90,0x98,0x14,0x13,0x50,0x30,0x00, //学0x04,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,0x06,0x05,0x04,0x04,0x04,0x06,0x04,0x00,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,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,0x80,0x40,0x20,0xF8,0x07,0x24,0x24,0x24,0x25,0x26,0x24,0x24,0xB4,0x26,0x04,0x00, //信0x00,0x00,0x00,0xFF,0x00,0x01,0xFD,0x45,0x45,0x45,0x45,0x45,0xFD,0x01,0x00,0x00,0x00,0x00,0x00,0xFC,0xA4,0xA6,0xA5,0xA4,0xA4,0xA4,0xA4,0xFE,0x04,0x00,0x00,0x00, //息0x40,0x30,0x00,0x77,0x84,0x84,0x8C,0x94,0xB4,0x84,0x84,0xE7,0x00,0x10,0x60,0x00,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, 0x24,0x24,0xA4,0xFE,0xA3,0x22,0x20,0x7E,0x42,0x42,0x42,0x42,0x42,0x7F,0x02,0x00, //程0x08,0x06,0x01,0xFF,0x00,0x43,0x41,0x49,0x49,0x49,0x7F,0x49,0x4D,0x69,0x41,0x00, 0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,0x90,0x90,0x98,0x14,0x13,0x50,0x30,0x00, //学0x04,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,0x06,0x05,0x04,0x04,0x04,0x06,0x04,0x00, 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};void main(){uchar i,line,colum ;uchar *address ;InitLcd();while(1){colum = 16;line = 1;address = HZ_tab;SetOnOff(0); //关显示for(i = 1;i < 7;i ++){if(i < 4)SelectScreen(0);elseSelectScreen(1);Show1616(line,colum ,address);colum += 16;if(colum >63)colum = 0;address += 32; //向DDRAM中写入数据}line = 5;colum = 0;for(i = 0;i <8; i ++){if(i < 4)SelectScreen(0);elseSelectScreen(1);Show1616(line,colum ,address);colum += 16;if(colum >63)colum = 0;address += 32;}SelectScreen(2);SetOnOff(1); // 开显示for(i = 0;i < 50;i ++) //延时LcdDelay(30000);}}/**********************************************。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
SendByte(0xf0&Cbyte); //高四位
SendByte(0xf0&Cbyte<<4); //低四位(先执行<<)
//RS = 0;
}
/*****写数据*****/
void Lcd_WriteData(uchar Dbyte )
for(y=110;y>0;y--);
}
void SendByte(uchar Dbyte)
{
uchar i;
for(i=0;i<8;i++)
{
E = 0;
Dbyte=Dbyte<<1; //左移一位
num++;
delayms(100);
}
}
void Lcd_Init(void);
void lcd_display();
void main()
{
Lcd_Init();
lcd_display();
while(1);
}
void delayms(uint z)
{
uint x,y;
for(x=z;x>0;x--)
temp1 = 0;
temp2 = 0;
for(i=0;i<8;i++)
{
temp1=temp1<<1;
E = 0;
E = 1;
E = 0;
uchar num;
void delayms(uint z); //不要忘了后面要加分号的!!!!
void SendByte(uchar Dbyte);
uchar ReceiveByte(void);
void Lcd_WriteCmd(ucharห้องสมุดไป่ตู้Cbyte );
void Lcd_WriteData(uchar Dbyte );
while(0x80&ReceiveByte()); //BF(.7)=1 Busy
}
/*****写指令*****/
void Lcd_WriteCmd(uchar Cbyte )
{
//RS = 1;
CheckBusy();
SendByte(0xf8); //11111,RW(0),RS(0),0
//RS = 0;
}
void Lcd_Init(void)
{
// PSB = 0;
// delayms(50);
Lcd_WriteCmd(0x30); //选择基本指令集
//delayms(1);
// Lcd_WriteCmd(0x30); //选择8bit数据流
{
Lcd_WriteCmd(0x80); //第一行显示
num=0;
while(table[num]!='\0')
{
Lcd_WriteData(table[num]);
num++;
delayms(100);
}
Lcd_WriteCmd(0x90); // 第二行显示
num=0;
while(table1[num]!='\0')
{
Lcd_WriteData(table1[num]);
num++;
delayms(100);
}
Lcd_WriteCmd(0x88); // 第三行显示
num=0;
while(table2[num]!='\0')
if(RW)
temp1++;
}
for(i=0;i<8;i++)
{
temp2=temp2<<1;
E = 0;
E = 1;
E = 0;
RW = CY; //移出的位给SID
E = 1;
E = 0;
}
}
/*****串行接收一个字节*****/
uchar ReceiveByte(void)
{
uchar i,temp1,temp2;
//sbit PSB = P0^3; //串并口选择 1:并口模式; 0:串口模式;
uchar code table[]="天津农学院";
uchar code table1[]="机电系";
uchar code table2[]="创新";
uchar code table3[]="全国电子设计大赛";
{
Lcd_WriteData(table2[num]);
num++;
delayms(100);
}
Lcd_WriteCmd(0x98); // 第四行显示
num=0;
while(table3[num]!='\0')
{
Lcd_WriteData(table3[num]);
delayms(1);
Lcd_WriteCmd(0x0c); //开显示(无游标、不反白)
delayms(1);
Lcd_WriteCmd(0x01); //清除显示,并且设定地址指针为00H
delayms(20);
}
void lcd_display()
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
//sbit RS = P1^0; //片选信号 lcd的RS端 可以不接
sbit RW = P1^1; //串行数据
sbit E = P1^2; //串行同步时钟
if(RW)
temp2++;
}
return ((0xf0&temp1)+(0x0f&temp2));
}
void CheckBusy( void ) //必须要检测LCD忙状态 这一步很重要
{
do SendByte(0xfc); //11111,RW(1),RS(0),0
{
//RS = 1;
CheckBusy();
SendByte(0xfa); //11111,RW(0),RS(1),0
SendByte(0xf0&Dbyte); //高四位
SendByte(0xf0&Dbyte<<4); //低四位(先执行<<)
相关文档
最新文档