AD转换12864显示成功版

合集下载

12864汉字液晶显示驱动程序

12864汉字液晶显示驱动程序

12864汉字液晶显示驱动程序模块主要硬件构成说明接口说明*注释1:如在实际应用中仅使用串口通讯模式,可将PSB接固定低电平,也可以将模块上的J8和“GND”用焊锡短接。

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

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

2.2并行接口管脚号管脚名称电平管脚功能描述1 VSS 0V 电源地2 VCC 3.0+5V 电源正3 V0 - 对比度(亮度)调整RS=“H”,表示DB7——DB0为显示数据4RS(CS)H/LRS=“L”,表示DB7——DB0为显示指令数据R/W=“H”,E=“H”,数据被读到DB7——DB0 5R/W(SID) H/LR/W=“L”,E=“H→L”, DB7——DB0的数据被写到IR或DR6 E(SCLK) H/L 使能信号7 DB0 H/L 三态数据线8 DB1 H/L 三态数据线9 DB2 H/L 三态数据线10 DB3 H/L 三态数据线11 DB4 H/L 三态数据线12 DB5 H/L 三态数据线13 DB6 H/L 三态数据线14 DB7 H/L 三态数据线15 PSB H/L H:8位或4位并口方式,L:串口方式(见注释1)16 NC - 空脚17 /RESET H/L 复位端,低电平有效(见注释2)18 VOUT - LCD驱动电压输出端19 A VDD 背光源正端(+5V)(见注释3)20 K VSS 背光源负端(见注释3)*注释1:如在实际应用中仅使用并口通讯模式,可将PSB接固定高电平,也可以将模块上的J8和“VCC”用焊锡短接。

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

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

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

12864液晶显示ADC电压值

12864液晶显示ADC电压值
#define DisTX (IE1 &= ~UTXIE0) //禁止发送中断//宋体字体开始地址
#include <msp430x14x.h>
#include "12864.c"
#include "Flash.c"
#include "ADC.C"
#include "LED.C"
//数码管段码;0--f
//Print(4,8,heiti,xianshi);
Print(4,8,heiti,xianshi1);
Print(4,16,heiti,".");
Print(4,24,heiti,xianshi2);
}
}
//数码管位选变量
uchar cnt = 0;
unsigned char shuzi[] = {"0123456789"};
static unsigned char xianshi[3];
static uint results[Num_of_Results]; //保存ADC转换结果的数组// is not used for anything.
P2DIR &= ~BIT6; //P2.6 input Flash
P6DIR |= BIT0;
P6OUT |= BIT0; //点亮LCD背光
//InitUART();
Initialize();
LCD_Clr();
for(int j=2;j>=0;j--)
{
for(int i=0;i<10;i++)
#define kaiti 0x802A0l //楷体字体开始地址

12864显示文字+图像

12864显示文字+图像

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

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

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

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

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

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

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

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

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

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

参见程序实例1。

12864显示图形

12864显示图形

看到工具箱旁边那个LCD12864很久没用了(当初买回来用的时候只是简单地测试了一下),于是萌生了重新写一次接口程序的想法(而且这次要给它加个图片显示的功能),好,说做就做,就用Atmega16和ICCAVR来做吧,最近这MCU和平台用得比较熟练。

马上从书堆里把当初打印出来的中文datasheet给翻了出来,依葫芦画瓢地写了个初始化程序。

好,OK。

编译通过。

于是又写了一个可以自定义从XY坐标值开始输出显示的函数,再次编译,也通过,OK。

于是呼马上写了四行简单的字符烧到单片机上试了一下,嘿嘿,一次通过。

如下图:后来在进一步测试的时候也出了点小问题。

就是我是使用USBISP烧写器把程序烧写进AVR的(此时实验板由USBISP烧写器供电),想要实现从第一行的第一个字符开始连续显示"0123456789"。

刚烧写完程序后能看到LCD12864上正常显示"0123456789",但是把烧写器从实验板上断开连接,单独用USB给实验板供电的时候,LCD的第一行只是显示"123456789",第一个字符消失了……,左思右想地弄了一个多小时后,终于把问题给解决了,就是把初始化程序的延时适当增加了些,真是奇怪。

刚开始一直想不通为什么在烧写器供电的情况下就正常显示,而换到USB供电后就出了问题。

后来再想想,估计是跟供电有关。

在使用USBISP烧写器供电的时候,LCD的背光灯明显比用USB供电的时候来得亮,而且对比度也高很多,看来是因为换到USB供电后,供电不怎么充足,以至于LCD在上电初始化的时候花上了更多的时间去初始化(因为供电低了,功率小了,跑起来有点力不从心,用的时间就久了嘛……我是觉得可以这样去理解的)接下来呢,就到了有点难度的画图了。

当初刚买到12864的时候只是简单测试了字符显示功能,除了因为画图还不需要用到,另外一个原因就是那datasheet上关于画图那部分的内容不怎么看得懂……。

stc12c5a60s2_AD采集_12864串行显示终极程序_带滤波

stc12c5a60s2_AD采集_12864串行显示终极程序_带滤波

stc12c5a60s2 AD采集12864串行显示终极程序带滤波作者:电子工程师(天津)由于AD采集电压并在12864上显示的程序很常用,然而网上很多程序各种各样,又有很多缺点,所以就利用工作之余的时间对用到的程序进行了整理,调试,优化以方便各位电子爱好者使用。

这段程序已经调试通过,改下io即可直接应用。

最后有两张效果图。

LCD_PSB=0;(并串选择口)LCD_RST =1;(复位口)注意:本程序用的是12864串行显示,将PSB引脚接地,RST拉高、片选口RS接高之后除了电源和地线,只用2根线就可以显示了,接线很方便,最大程度的节省了io口。

本程序是以电流采集为例的,采集的是电流传感器输出的电压,然后转换成电流,如果只需要采集电压的话将转化为电流的语句删除即可。

AD是stc12c5a60s2 自带的10位AD。

使用很方便。

有不明白的可以qq联系我,1264136841#include"stc12c5a60s2.h"#include"intrins.h"float ADvalue = 0;unsigned int volage = 0;unsigned int current = 0;void InitializeDisplay();void InitializeLcd12864();void displaystring(unsigned char add,unsigned int num);void WriteCommandLcd12864(unsigned char temp);void InitializeDisplay();void InitializeAD();unsigned int ReadADvalue(unsigned char channel);float SmoothingFilter(unsigned int temp);void Delay_us(unsigned int xus);void Delay_ms(unsigned int xms);sbit LCD_SID = P2^5;//即RW口sbit LCD_CLK = P2^6;//即E口code unsigned char name1[] = {"escrewdriver"};code unsigned char name2[] = {"电流采集显示"};code unsigned char name3[] = {"电流: A "};code unsigned char name4[] = {"参数:mm "};"};void main(){// InitializeAD();// InitializeTimer0();// InitializeUart();InitializeLcd12864();InitializeDisplay();while(1){ADvalue = ReadADvalue(0); //读回AD值ADvalue = ADvalue*5000/1024; //转换成电压值/* if(ADvalue > 2500) //防止电压浮动在2.5V以上ADvalue = 2500;ADvalue = 2500-ADvalue; //电流反方向流过传感器,输出电压值小于2.5V,*/current = (ADvalue*8); //计算电流,每0.625V代表7.5A 即每1V代表12Acurrent = SmoothingFilter(current); //进行一下平滑滤波displaystring(0x8b,current);displaystring(0x9b,0.5*current);}}/*********************延时函数******************************/void Delay_us(unsigned int xus) //@11.0592MHz{while(xus-->0){_nop_();_nop_();_nop_();}}void Delay_ms(unsigned int xms) //@11.0592MHz{unsigned int y=0;for(;xms>0;xms--)for(y=0;y<600;y++);}/*******************延时函数*****************************//*******************************************************//********************lcd12864显示部分*******************//*******************************************************/void InitializeLcd12864()WriteCommandLcd12864(0x30);//基本功能WriteCommandLcd12864(0x0c);//显示开,光标关WriteCommandLcd12864(0x01);//清屏}void WriteByteLcd12864(unsigned char temp){unsigned char i;LCD_CLK = 0;for(i=0;i<8;i++){if(temp&0x80)LCD_SID = 1;elseLCD_SID = 0;LCD_CLK = 1;Delay_us(10);temp <<= 1;LCD_CLK = 0;Delay_us(10);}}void WriteCommandLcd12864(unsigned char temp){WriteByteLcd12864(0xf8);WriteByteLcd12864(temp&0xf0);WriteByteLcd12864(temp<<4);}void WriteDataLcd12864(unsigned char temp){WriteByteLcd12864(0xfa);WriteByteLcd12864(temp&0xf0);WriteByteLcd12864(temp<<4);}void WriteStringAddress(unsigned char add,unsigned char length,unsigned char *temp) {WriteCommandLcd12864(add);for(;length>0;length--){WriteDataLcd12864(*temp);temp++;}/***显示电压和电流***/void displaystring(unsigned char add,unsigned int num){unsigned char buf[10],i;buf[0] = num/10000;buf[1] = num%10000/1000;buf[2] = num%1000/100;buf[3] = num%100/10;buf[4] = num%10;WriteCommandLcd12864(add);for(i=0;i<5;i++){WriteDataLcd12864(buf[i]+0x30);if(i == 1) WriteDataLcd12864('.');}}/***显示内容初始化***/void InitializeDisplay(){WriteStringAddress(0x81,12,name1);WriteStringAddress(0x91,12,name2);WriteStringAddress(0x88,16,name3);WriteStringAddress(0x98,16,name4);Delay_ms(100);// WriteStringAddress(0x98,6,name5);}/********************lcd12864显示部分*******************/ /*******************************************************//*******************************************************/ /********************AD采集部分*************************/ /*******************************************************/ /***AD初始化***/void InitializeAD(){P1ASF=0xff ; //P1口全部作为模拟功能AD使用ADC_RES=0; //清零转换结果寄存器高8位ADC_RESL=0; //清零转换结果寄存器低2位ADC_CONTR=0x80;//开启AD电源Delay_ms(1); //等待1ms,让AD电源稳定}/***读对应通道AD值***/unsigned int ReadADvalue(unsigned char channel){ADC_CONTR=0x88|channel; //开启AD转换1000 1000 即POWER SPEED1 SPEED0 ADC_FLAG ADC_START CHS2 CHS1 CHS0_nop_();_nop_();_nop_();_nop_();//要经过4个CPU时钟的延时,其值才能够保证被设置进ADC_CONTR 寄存器while(!(ADC_CONTR&0x10)); //等待转换完成ADC_CONTR&=0xe7; //关闭AD转换,ADC_FLAG位由软件清0return(ADC_RES*4+ADC_RESL); //返回AD转换完成的10位数据(16进制)}/***实时平滑滤波***/float SmoothingFilter(unsigned int temp){static unsigned int i=0;static unsigned int buf[10];float average = 0;if(i>=10)i=0;buf[i++] = temp;average = (average+buf[0]+buf[1]+buf[2]+buf[3]+buf[4]+buf[5]+buf[6]+buf[7]+buf[8]+buf[9])/10;return average;}/*******************************************************//*******************************************************/。

显示正常的12864程序1

显示正常的12864程序1
// delayus(100);
delayus(5000);
lcd_write_data_command(comm,0x06);//光标的移动方向。cd
// delayus(100);
lcd_write_data_command(comm,0x02);//清除显示。并使DDRAM地址计数器归0.
// delayus(100);
lcd_write_data_command(comm,0x30);//
// delayus(100);
lcd_write_data_command(comm,0x0c);//开显示,关游标。
// delayus(100);
lcd_write_data_command(comm,0x01);//清屏,地址指针指向00H。
InitGpio(); //初始化GPIIO口。
InitLcd();
lcd_write_data_command(comm,0x80);
delayus(100); //这人也要延时,否则,数据写不进去。
en=0;
// delayus(100); //
}
void delayus(unsigned int tus) //一个脉冲为1/15us ,所以为tus*100/150us。
江勇+刘瑞*/
//算法:可以把每一行作为一个整体(字符串格式)放到一个字符串组内部,这样总共四个数组。
//显示的时候,只要设置好每行的首地址,就可以依次将数组内的字符显示到显示屏的所在行。
void InitGpio(void)
{
EALLOW;
// 在这里插入初始化函数的代码

51单片机示波器制作(12864显示带字库)

51单片机示波器制作(12864显示带字库)

51单⽚机⽰波器制作(12864显⽰带字库)⾸先说明:我才接触51单⽚机3个星期(6⽉8号才⾼考完),对C语⾔还很陌⽣。

我就是⼀个萌新,还希望⼤佬们多多指导。

12864(带字库st7920驱动)为显⽰器,XPT2046为AD转换芯⽚。

(不要问我为什么⽤这个芯⽚,开发板⾃带的坑货。

我在⽹上下载的⽰波器程序⼤多以ADC0832或ADC0808为AD转换芯⽚,结果我都⽤不了,所以才被迫⾃写程序。

)⽰波器程序由main.c XPT2046.c XPT2046.h三个⼦⽂件构成,main.c是我根据⽹上的⼀个12864画图程序改编⽽成我也加了⼀些注释,后⾯两个⽂件取⾃开发板⾃带的例程并进⾏了修改。

所以说这个程序基本上不是我编写的,也有很多问题和不⾜之处还请指正。

下⾯是效果图。

⾸先是⽅波。

由于没有函数发⽣器,就只能通过⼿机播放只做好的正弦⾳频,再检测⼿机⽿机接⼝信号。

不知道为什么,正弦波有⼀半不见了,似乎是由于不能检测到负电压还是什么的。

下⾯贴出main.c 的代码。

01.#include <reg52.h>02.#include"XPT2046.h" 03.#define uint unsigned int 04.#define uchar unsigned char05.06.sbit RS=P2^6; //LCD 数据或命令选择端07.sbit RW=P2^5; //LCD 写⼊或读出选择端08.sbit RST=P1^0; //LCD 复位端⼝09.sbit LCDE=P2^7; // LCD 使能端10.sbit PSB=P3^2;//串⾏或并⾏选择端11.12. void delay(uchar i)13. {14. while(i--);15. } //延时函数,i=1时延时约10微秒(12M晶振)16.17. void SPI_Start()18. {19. CLK = 0;20. CS = 1;21. DIN = 1;22. CLK = 1;23. CS = 0;24. } //ADC芯⽚(XPT2046)初始化函数25.26. void lcd_busy()27.28. {29.30. RS=0;31.32. RW=1;33.34. P0=0XFF;35.36. LCDE=1;37.38. delay(14);39.40. while((P0&0x80)==0x80);41. LCDE=0;42.43. }//LCD12864(st7920驱动)查忙函数44.45. void write_com(uchar com)46.47. {48.49. lcd_busy();RS=0;50.51. RW=0;52.53. LCDE=0;54.55. P0=com;56.57. delay(9);58.59. LCDE=1;60.61. delay(9);62.63. LCDE=0;64.65. }//LCD写指令函数66.67. void write_num(uchar num)68.69. {70.71. lcd_busy();72.73. RS=1;75. RW=0;76.77. LCDE=0;78.79. P0=num;80.81. delay(7);82.83. LCDE=1;84.85. delay(9);86.87. LCDE=0;88.89. }//LCD写数据函数90.91. uchar read_data()92.93. {94.95. uchar read;96.97. lcd_busy();98.99. RS=1;100.101. RW=1;102.103. LCDE=0;104.105. delay(7);106.107. LCDE=1;108.109. delay(9);110.111. read=P0;112.113. LCDE=0;114.115. delay(11);;116.117.118.119. return read;120.121. } //LCD读数据函数122.123. void clear_lcd()124.125. {126.127. uchar i,j;128.129. write_com(0x34);130.131. for(i=0;i<32;i++) //因为LCD有纵坐标32格所以写三⼗⼆次132.133. {134.135. write_com(0x80+i); //先写⼊纵坐标Y的值137. write_com(0x80); //再写⼊横坐标X的值138.139. for(j=0;j<32;j++) //横坐标有16位,每位写⼊两个字节的的数据,也就写⼊32次140.141. { //因为当写⼊两个字节之后横坐标会⾃动加1,所以就不⽤再次写⼊地址了。

12864液晶显示程序

12864液晶显示程序

12864液晶显示程序#include <reg51.h>#include <intrins.h>sbit RS = P2^5;sbit RW = P2^6;sbit E = P2^7;sbit RES = P3^5;#define Lcd_Bus P0 //MCU P1<------> LCM#define FIRST_ADDR 0 //定义字符/汉字显示起始位置unsigned char code zk[]={0x08,0x20,0x1c,0x10,0x1c,0x1c,0xff,0x9e,0x7f,0x1e,0x1c,0x1f,0x3e,0x1f,0x3e,0x1f, 0x77,0x1f,0x41,0x3f,0x00,0x7e,0x00,0xfe,0x83,0xfc,0x7f,0xf8,0x3f,0xf0,0x0f,0xc0, };unsigned char code BMP1[]={/*-- 调入了一幅图像:D:\3033B\3033.bmp --*//*-- 宽度x高度=128x64 --*//*--总共52行数据,每行16个数据--*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x0C,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x08,0x00,0x00,0x00,0x00,0x00,0x07,0xF1,0x00,0x03,0x01,0x00,0xF0,0x00,0x00,0x00, 0x18,0x00,0x00,0x00,0x00,0x00,0x04,0x01,0x00,0x03,0x81,0x08,0x98,0x00,0x00,0x00, 0x10,0x1F,0x07,0x06,0x00,0x00,0x08,0x01,0x00,0x04,0x81,0x11,0x88,0x00,0x00,0x00, 0x10,0x21,0x0D,0x83,0xE3,0xC0,0x0F,0x02,0x00,0x04,0xC1,0x31,0x30,0x00,0x00,0x00, 0x10,0x21,0x18,0x83,0x06,0x40,0x09,0x82,0x00,0x0F,0xC1,0x21,0xE0,0x00,0x00,0x00, 0x10,0x2E,0x11,0x86,0x06,0x40,0x00,0x86,0x00,0x08,0x43,0xC3,0xE0,0x00,0x00,0x00, 0x30,0x30,0x11,0x86,0x04,0x40,0x41,0x84,0x10,0x18,0x63,0x82,0x18,0x00,0x00,0x00, 0x20,0x1E,0x1F,0x84,0x04,0x60,0x7E,0x04,0x08,0x10,0x23,0x04,0x0E,0x00,0x00,0x00, 0x3F,0x83,0x00,0xE0,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x38,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x6C,0x3C,0x00,0x20,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x42,0x22,0x03,0xFD,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x40,0x62,0x00,0x22,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x46,0x42,0x00,0x22,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x44,0x42,0x00,0x23,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x7C,0x26,0x00,0x2D,0xB0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x0C,0x3C,0x00,0x38,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x04,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x06,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x02,0x30,0x00,0x00,0x00,0x00,0x00,0x01,0xF0,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x01,0xE0,0x00,0x00,0x00,0x00,0x00,0x03,0x18,0x08,0x0C,0x30,0xF1,0x08,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x08,0x08,0x0C,0x31,0x91,0x08,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x08,0x08,0x1A,0x71,0x01,0x08,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x08,0x13,0xD1,0x01,0x08,0x00, 0x00,0x00,0x08,0x11,0x0A,0x00,0x20,0x20,0x04,0x04,0x18,0x11,0x91,0x01,0x08,0x00, 0x00,0x00,0x04,0x11,0x12,0x31,0x22,0x20,0x04,0x04,0x10,0x11,0x13,0x01,0x08,0x00, 0x00,0x00,0x02,0x1B,0x92,0x31,0x26,0x20,0x04,0x04,0x10,0x10,0x12,0x01,0x08,0x00, 0x3F,0xFF,0xFF,0x0A,0x91,0x73,0x25,0x60,0x04,0x44,0x10,0x10,0x12,0x01,0x08,0x00, 0x00,0x00,0x02,0x0A,0xB1,0x4A,0x35,0x40,0x04,0x34,0x30,0x10,0x13,0x01,0x08,0x00, 0x00,0x00,0x04,0x0E,0x61,0xCA,0x19,0x40,0x04,0x1C,0x20,0x10,0x11,0x19,0x98,0x00, 0x00,0x00,0x08,0x04,0x60,0xCC,0x19,0xCC,0x06,0x0E,0x20,0x10,0x11,0xF0,0xFC,0xC0, 0x00,0x00,0x00,0x04,0x60,0x8C,0x18,0x8C,0x03,0xF3,0xBF,0x80,0x00,0x00,0x00,0xC0, 0x00,0x00,0x00,0x00,0x40,0x80,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x83,0x80,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x06,0xC3,0xFC,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x08,0x22,0x44,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x08,0x22,0x42,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x08,0x26,0x42,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x08,0x24,0x42,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x48,0x64,0x42,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0xC4,0x44,0x42,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x03,0x84,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};unsigned char code BMP[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x04,0x20,0x00,0x00,0x00,0x00, 0x1F,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x84,0x42,0x00,0x00,0x00,0x00, 0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x40,0x84,0x00,0x00,0x00,0x00, 0x00,0x03,0x80,0x00,0x00,0x00,0x00,0x00,0xE0,0x04,0x00,0x08,0x80,0x60,0x00,0x00, 0x00,0x1F,0xFF,0xC0,0x00,0x00,0x00,0x01,0x10,0x02,0x1F,0xC1,0x01,0xD0,0x00,0x38, 0x00,0x00,0x00,0x01,0xFC,0x00,0x00,0x00,0x10,0x00,0x70,0x72,0x01,0x0C,0x00,0x68, 0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x06,0x13,0x08,0x40,0x08,0x03,0x06,0x00,0xCC, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x09,0x84,0x80,0x0C,0x1E,0x03,0x89,0x86, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0xC1,0x80,0x04,0x68,0x00,0xFF,0x02, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x41,0x00,0x00,0xC0,0x00,0x60,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x61,0x00,0x00,0x80,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x31,0x00,0x00,0x80,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x0C,0x00,0x00,0x80,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x04,0x00,0x01,0x80,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x06,0x00,0x01,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x02,0x00,0x02,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x38,0x00,0x00,0x00,0xC0,0x00,0x03,0x00,0x02,0x00,0x00,0x00,0x00, 0x00,0x00,0x01,0xE8,0x00,0x00,0x01,0x80,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x1A,0x08,0x00,0x00,0x03,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x08,0x00,0x00,0x02,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x08,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x10,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x3C,0x18,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x01,0xC0,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x03,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x02,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x02,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x04,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x04,0x00,0x02,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x01,0xF4,0x00,0x02,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x01,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x03,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x79,0xF8,0x10,0x20,0x00, 0x02,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x09,0x08,0x10,0x20,0x00, 0x02,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x09,0x08,0x10,0x20,0x00, 0x06,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x79,0xF8,0x10,0x20,0x00, 0x04,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0xFD,0xFE,0x00, 0x04,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x43,0xFC,0x10,0x20,0x00, 0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x03,0xFF,0xF0,0x42,0x44,0x10,0x60,0x00, 0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x7A,0x44,0x38,0x70,0x00, 0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x0B,0xFC,0x74,0xB0,0x00, 0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x08,0x40,0x54,0xA8,0x00, 0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x08,0x48,0x91,0x28,0x00, 0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x08,0x44,0x12,0x26,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x7E,0x14,0x24,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2B,0xC4,0x10,0x20,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x20,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, };/*------------------检查忙位-----------------------------*/void chk_busy(){ RS=0;RW=1;E=1;Lcd_Bus=0xff;while((Lcd_Bus&0x80)==0x80);E=0;}/*------------------延时子程序-----------------------------*/void delay(unsigned int t){ unsigned int i,j;for(i=0;i<t;i++)for(j=0;j<10;j++);}/*------------------写命令到LCD------------------------------*/void write_com(unsigned char cmdcode){chk_busy();RS=0;RW=0;E=1;Lcd_Bus=cmdcode;delay(5);////////////////////在数据写入的时候加入适当的延时E=0;delay(5);}/*-------------------写数据到LCD----------------------------*/void write_data(unsigned char Dispdata){chk_busy();RS=1;RW=0;E=1;Lcd_Bus=Dispdata;delay(5);///////////////////在数据写入的时候加入适当的延时E=0;delay(5);}/*------------------初始化LCD屏--------------------------*/void lcdreset(){ delay(2000);write_com(0x30);delay(10); //选择基本指令集write_com(0x30); //选择8bit数据流delay(5);write_com(0x0c); //开显示(无游标、不反白)delay(10);write_com(0x01); //清除显示,并且设定地址指针为00Hdelay(500);write_com(0x06); //指定在资料的读取及写入时,设定游标的移动方向及指定显示的移位delay(0);}/*------------------自定义一个字符代码(一个星星和月亮)--------------------------*/void CGRAM(){ int i;write_com(0x30);write_com(0x40);for(i=0;i<16;i++){write_data(zk[i*2]);write_data(zk[i*2+1]);}}/*------------------显示字符串--------------------------*/void hzkdis(unsigned char code *s){ while(*s>0){ write_data(*s);s++;delay(50);}}/*------------------首屏显示--------------------------*/void ceshi(){write_com(0x01);//清除显示,并且设定地址指针为00Hdelay(5);write_com(0x80);//第一行(如果是地址是:80H,即LCD的第一行的第一个位置显示)hzkdis("----强林单片机");write_com(0x90);//第二行(如果是地址是:90H,即LCD的第二行的第一个位置显示)hzkdis("--技术项目交易网");write_com(0x88);//第三行(如果是地址是:88H,即LCD的第二行的第一个位置显示)hzkdis("LCD12864点阵液晶");write_com(0x9A);//第四行(如果是地址是:98H,即LCD的第二行的第一个位置显示)hzkdis("测试程序");}/*------------------显示图片------------------------2005.11.14.21:20修改---benladn911---*/void Disp_Img(unsigned char code *img){ unsigned int j=0;unsigned char x,y,i;for(i=0;i<9;i+=8)for(y=0;y<32;y++)/*原来为 y<26 ,上下两个半屏不能正常对接显示,导致显示的图片中间有空隙*/ for(x=0;x<8;x++){ write_com(0x36);//功能设置---8BIT控制界面,扩充指令集write_com(y+0x80); //行地址write_com(x+0x80+i); //列地址write_com(0x30);write_data(img[j++]);write_data(img[j++]);}}/*------------------清整个GDRAM空间----------------------------*/void clrgdram(){ unsigned char x,y;for(y=0;y<64;y++)for(x=0;x<16;x++){ write_com(0x34);write_com(y+0x80); //行地址write_com(x+0x80); //列地址write_com(0x30);write_data(0x00);write_data(0x00);}}/*------------------整屏写入数据:全亮,或者竖条-----------------------------*/void lcdfill(unsigned char disdata){ unsigned char x,y;for(y=0;y<32;y++)for(x=0;x<16;x++){ write_com(0x36);write_com(y+0x80); //行地址write_com(x+0x80); //列地址write_com(0x30);write_data(disdata);write_data(disdata);}write_com(0x34);write_com(0x36);}/*------------------显示横-----------------------------*/void Disp_H_Line(){ unsigned char x,y;unsigned char k=0x00;for(y=0;y<32;y++){ k=~k;for(x=0;x<16;x++){ write_com(0x36);write_com(y+0x80); //行地址write_com(x+0x80); //列地址write_com(0x30);write_data(k);write_data(k);};}write_com(0x34);write_com(0x36);}/*------------------显示边框-------------------------------*/void Frame(){unsigned char x,y;lcdfill(0x00);for(x=0;x<9;x+=8)for(y=0;y<32;y++){ write_com(0x36);write_com(y+0x80); //行地址write_com(x+0x80); //列地址write_com(0x30);write_data(0x80);write_data(0x00);write_com(0x36);write_com(y+0x80); //行地址write_com(x+0x87); //列地址write_com(0x30);write_data(0x00);write_data(0x01);}for(y=0;y<2;y++)for(x=0;x<8;x++){write_com(0x36);write_com(y*31+0x80); //行地址write_com(x+0x80+8*y); //列地址write_com(0x30);write_data(0xff);write_data(0xff);}write_com(0x34);write_com(0x36);}/*------------------在第7列的位置加入两条竖线--------------------------*/ void shuxian(){ unsigned char x,y;for(x=0;x<9;x+=8)for(y=0;y<32;y++){ write_com(0x36);write_com(y+0x80); //行地址write_com(x+0x86); //列地址write_com(0x30);write_data(0x00);write_data(0x14);};}/*------------------清屏命令--------------------------*/void clrscreen(){write_com(0x01);delay(10);}/*------------------唐诗《静夜思》--------------------------*/void gushi_display(){ write_com(0x30);clrscreen();write_com(0x80+FIRST_ADDR);hzkdis("床前明月光,");write_com(0x90+FIRST_ADDR);hzkdis("疑是地上霜。

12864串行显示(字符、字符串)

12864串行显示(字符、字符串)

12864串行显示(字符、字符串)/************************************************************** ******* 文件名:串行12864显示.c* 描述 : 该程序实现了12864以串行的方式进行通信。

液晶上的R9。

R10决定液晶的串行或者并行通讯方式。

液晶上的PSB已经拉为高电平。

如果使用串行,需要取掉R9。

* 创建人:* 版本号:*************************************************************** ********/#include#include#define uchar unsigned char#define uint unsigned intsbit CS=P2^5; //片选信号sbit SID=P2^6; //数据信号sbit SCLK=P2^7; //时钟信号sbit RST=P2^2; //复位信号sbit CH = P2^4; //并行、串行选择信号/************************************************************** ******* 名称 : delay()* 功能 : 延时,延时时间为 100us * t。

这是通过软件延时,有一定误差。

* 输入 : t* 输出 : 无*************************************************************** ********/void delay(unsigned int t){unsigned int i,j;for(i=0; ifor(j=0; j<10; j++);}/************************************************************** ******* 名称 : sendbyte()* 功能 : 按照液晶的串口通信协议,发送数据* 输入 : zdata* 输出 : 无*************************************************************** ********/void sendbyte(unsigned char zdata){unsigned int i;for(i=0; i<8; i++){if((zdata << i) & 0x80){SID = 1;}else{SID = 0;}SCLK = 0;SCLK = 1;}}/************************************************************** ******* 名称 : write_com()* 功能 : 写串口指令* 输入 : cmdcode* 输出 : 无*************************************************************** ********/void write_com(unsigned char cmdcode){CS = 1;sendbyte(0xf8);sendbyte(cmdcode & 0xf0);sendbyte((cmdcode << 4) & 0xf0);delay(2);}/************************************************************** ******* 名称 : write_data()* 功能 : 写串口数据* 输入 : cmdcode* 输出 : 无***********************************************************************/void write_data(unsigned char Dispdata){CS = 1;sendbyte(0xfa);sendbyte(Dispdata & 0xf0);sendbyte((Dispdata << 4) & 0xf0);delay(2);}/************************************************************** ******* 名称 : lcdinit()* 功能 : 初始化函数* 输入 : cmdcode* 输出 : 无*************************************************************** ********/void lcdinit(){RST = 0;delay(100);RST = 1;delay(20000);write_com(0x30);delay(50);write_com(0x0c);delay(50);}/************************************************************** ******* 名称 : L1602_num(uchar hang,uchar lie,char sign)* 功能 : 改变液晶中某位的值,如果要让第一行,第五个字符显示(0~9) ,调用该函数如下L1602_char(1,5,9)* 输入 : 行,列,需要输入1602的数据* 输出 : 无*************************************************************** ********/void L12864_num(uchar hang,uchar lie,char sign){switch(hang){case 1: write_com(0x80+lie);break;case 2: write_com(0x90+lie);break;case 3: write_com(0x88+lie);break;case 4: write_com(0x98+lie);break;default:break;}write_data(sign+48);}/************************************************************** ******* 名称 : L1602_char(uchar hang,uchar lie,char sign)* 功能 : 改变液晶中某位的值,如果要让第一行,第五个字符显示"b" ,调用该函数如下L1602_char(1,5,'b')* 输入 : 行,列,需要输入1602的数据* 输出 : 无*************************************************************** ********/void L12864_char(uchar hang,uchar lie,char sign){switch(hang){case 1: write_com(0x80+lie);break;case 2: write_com(0x90+lie);break;case 3: write_com(0x88+lie);break;case 4: write_com(0x98+lie);break;default:break;}//write_data(00);write_data(sign);}/************************************************************** ******* 名称 : L1602_string(uchar hang,uchar lie,uchar *p)* 功能 : 改变液晶中某位的值,如果要让第一行,第五个字符开始显示"ab cd ef" ,调用该函数如下L1602_string(1,5,"ab cd ef;")* 输入 : 行,列,需要输入1602的数据* 输出 : 无*************************************************************** ********/void L12864_string(uchar hang,uchar lie,uchar *p){switch(hang){case 1: write_com(0x80+lie);break;case 2: write_com(0x90+lie);break;case 3: write_com(0x88+lie);break;case 4: write_com(0x98+lie);break;default:break;}while(*p>0){write_data(*p);p++;}}/************************************************************** ******* 名称 : Test()* 功能 : 显示子函数* 输入 : 无* 输出 : 无*************************************************************** ********/void Test(){//write_com(0x03);//delay(50);L12864_num(1,0,8);L12864_char(2,0,'m');L12864_string(3,0,"sffds");L12864_string(4,0,"是电池");}/************************************************************** ******* 名称 : Main()* 功能 : 主函数* 输入 : 无* 输出 : 无*************************************************************** ********/void Main(){CH = 0;delay(1);lcdinit();delay(10);while(1){Test();delay(5000);}}。

12864液晶图像显示图文教程——最全版

12864液晶图像显示图文教程——最全版
2:1 的过程中图片会被拉伸变形,不过缩小到 128*64 像素后也不 是太明显。 也可以使用 windows 操作系统自带的绘图工具修改图片大小,并保存为.bmp 格式文件,再利用自摸 提取软件提取字模。 例子如下:(该图片是利用 Photoshop 软件编辑而成的,像素 128*64,经绘图工具保存为.bmp 格式)
uchar i,j; write_cmd(0x34);//扩充指令集动作 write_cmd(0x34);//关绘图显示功能 for(i=0;i<32;i++)//上半屏 { write_cmd(0x80+i);//垂直地址 write_cmd(0x80); //水平地址,水平地址自动加 1 for(j=0;j<16;j++) { write_data(0x00); } } for(i=0;i<32;i++)//下半屏 { write_cmd(0x88+i);//垂直地址 write_cmd(0x88);//水平地址,水平地址自动加 1 for(j=0;j<16;j++) { write_data(0x00); } } write_cmd(0x36);//开绘图显示 write_cmd(0x30);//回到基本指令集 } //函数名称:display_image(uchar *p) //函数功能:显示图片 void display_image(uchar *p) { uchar i,j; write_cmd(0x34);//扩充指令集动作 write_cmd(0x34);//关绘图显示功能 /*上半屏显示设置*/ for(i=0;i<32;i++)//上半屏 { write_cmd(0x80+i);//垂直地址 write_cmd(0x80); //水平地址,水平地址自动加 1

AD采样以及12864液晶显示成功程序

AD采样以及12864液晶显示成功程序
if(dat_comm)
sid=1; //数据
else
sid=0; //指令
clk=1;// rw完成
clk=0;//进行传送
sid=0;// rs=0,显示指令数据
clk=1;//
clk=0;//传送'0'
while(temp!=0xf0)//有键按下
{
delay(5);
temp=P0;
temp=temp&0xfe;
while(temp!=0xf0)
{
temp=P0;
switch(temp)
{
case 0x7b:num=7;break;
}
sid=0;
for(i=0;i<4;i++)
{
clk=1;
clk=0;
}
}
} /*一次攒的数据八位*/
/*---------------显示汉字或字符----------------*/
uint ad0809_dy()
{
uint ad_0809;
ABC=0;//选通通道,ABC同时接A8
oe=0;//以下三条指令为起动AD0809
st=0;
st=1;
st=0;
delay(1);
while(!eoc);//等待转换结束
oe=1;//取出读得的数据
case 0xbb:num=8;break;
case 0xdb:num=9;break;
case 0xeb:num=12;break;
}
while(temp!=0xf0)//松手检测

12864LCD液晶显示原理及使用方法

12864LCD液晶显示原理及使用方法

12864LCD液晶显示原理及使用方法
液晶显示原理:
液晶材料具有两个特点:有机分子结构和束缚之外的液态状态。

当电
场施加在液晶分子上时,液晶分子将会排列成有序的状态,形成有规律的
分子阵列,使得光线通过时发生偏转。

当电场消除时,液晶分子恢复到原
始的无序状态,光线通过时则无偏转。

通过控制电场的开关,可以控制液
晶分子的排列状态,从而实现显示效果。

1.接口连接:将液晶显示器与控制器或者主控板通过正确的接口连接,通常使用平行接口或者SPI接口。

2.电源连接:将电源线正确连接到液晶显示器上,通常有正负两极,
要连接正确以保证电源供应的正常。

3.控制信号输入:根据控制器或者主控板的要求,输入相应的数据和
控制信号。

如数据线、时钟线、片选线等。

4.编程:根据液晶显示器的要求,通过程序编程,设置相应的显示模式、亮度、对比度等参数。

5.数据传输:通过数据线将需要显示的信息传输到液晶显示器上,并
且根据编程的设置,显示出相应的图像或文字。

使用注意事项:
1.温度:液晶显示器对温度敏感,使用时应保持在合适的温度范围内,一般在0℃-50℃之间。

2.湿度:湿度过高或过低对液晶显示器都会有影响,要避免潮湿的环
境和液体直接接触。

3.防护:避免受到力的撞击以及接触尖锐物体,这样会导致液晶显示器损坏。

4.清洁:定期使用干净、柔软的布擦拭液晶显示器,避免使用化学物品或者刷子擦拭,以免划伤显示屏。

总结:。

12864多变量显示成功程序

12864多变量显示成功程序

#include <reg51.h>#define uchar unsigned char //宏定义#define uint unsigned int#define lcdbus P1sbit RS = P2^2;sbit RW =P2^1;sbit E = P2^0;sbit st=P3^2;sbit eoc=P3^4;sbit oe=P3^3;sbit A=P3^5;sbit B1=P3^6;sbit C=P3^7;void display(uchar);void busy();uchar table1[]={"0123456789.V"};void delay(uint z) //0.1MS 准确延时 z=1 {uint x,y;for (x=0;x<z;x++)for(y=0;y<11;y++);}void write_com(uchar xiezl) //写指令{busy();RS=0;RW=0;E=1;lcdbus=xiezl;delay(5);E=0;delay(5);}void busy() //查忙{ RS=0;RW=1;E=1;lcdbus=0xff;while((lcdbus&0x80)==0x80);E=0;}void write_data(uchar xiesj) //写数据{busy();RS=1;RW=0;E=1;lcdbus=xiesj;delay(5);E=0;delay(5);}void xianshi(uchar code *s) //用指针显示字符串{ //各种字符都用字符串显示出来方法简单 while(*s>0){write_data(*s);s++;delay(10);}}void xianshi2(uchar code *s) //用指针显示字符串{ //各种字符都用字符串显示出来方法简单 while(*s>0){write_data(*s);s++;delay(10);}}void lcdcsh() //液晶初始化{ delay(2000);write_com(0x30);delay(10);write_com(0x30);delay(5);write_com(0x0c); //开显示(无游标、不反白)delay(10);write_com(0x01); //清除显示,并且设定地址指针为00Hdelay(500);write_com(0x06); //指定在资料的读取及写入时,设定游标的移动方向及指定显示的移位delay(10);}void main(){ uchar adc;lcdcsh();while(1){ write_com(0x01);delay(5);write_com(0x81);xianshi("欢迎各校领导:");delay(5);write_com(0x90);xianshi("来创新实验室进行");delay(5);write_com(0x88);xianshi("工作指导!");delay(5);write_com(0x9a);xianshi("--创新实验室");delay(50000);write_com(0x01);delay(5);while(1){ A=1;B1=1;C=0;st=0;delay(5);st=1;delay(5);st=0;if(eoc==0);if(oe==0);adc=P0;delay(10);write_com(0x80);xianshi2("当前温度: 0.00V");display(adc);delay(5);write_com(0x90);xianshi2("当前时间: 10S");delay(5);write_com(0x88);xianshi2("前方距离: 110cm");delay(5);write_com(0x98);xianshi2("速度:10cm/s");delay(50000);}}}void display(uchar adc){ uint a,b,c;write_com(0x85);a=adc/51;write_data(table1[a]);delay(10);write_data(table1[10]) ;delay(10);b=((adc%51)*10)/51;if(adc%51>25)b=((adc%51)*10)/51+5;write_data(table1[b]);delay(10);c= ((adc%51)*10)%51*10/51;if(((adc%51)*10)%51>25)c=((adc%51)*10)%51*10/51+5;write_data(table1[c]);delay(10);}。

双通道相位差可调正弦信号发生器程序(AD9850,12864显示)

双通道相位差可调正弦信号发生器程序(AD9850,12864显示)

/******************************************************************************主程序部分******************************************************************************/ #include<reg52.h>#include<intrins.h>#include<12864.h>#include<AD9850.h>#include<IR.h>#define uchar unsigned char#define uint unsigned intuchar h1[]={"CH1: Hz "};uchar h2[]={"CH2: Hz "};uchar h3[]={"Δφ: . ° "};uchar h4[]={"V1:2.3V V2:2.3V"};long int fa=1000,fb=1000,ph=0,f=0;//定义A、B通道初始频率,初始相位,频率中间变量long int ph_disp=0;//相位显示变量,实际相位增量为11.25时,控制字增量为8long int n=0;//Vol+或V ol-按下的次数,在相位显示时用uchar h=2;//定义行参数,初始显示为第二行bit H_ok=1;//行选择完成标志位bit Num_ok=1;//数字输入完成标志位bit Step_ok=1;//步进输入完成标志位bit Sel_ok=1;//选择成功标志位bit LCD_ok=1;//写LCD完成标志位bit AD9850_ok=1;//写AD9850完成标志位void change()//将实际数值在12864上显示进行要的处理{h1[7]='0'+fa/100000;h1[8]='0'+fa/10000%10;h1[9]='0'+fa/1000%10;h1[10]='0'+fa/100%10;h1[11]='0'+fa/10%10;h1[12]='0'+fa%10;if(h==1)if(Sel_ok==1) h1[15]='*';//显示当前所在行else h1[15]='-';//数字输入等待状态显示-else h1[15]=' ';//调整项不在此行显示为空h2[7]='0'+fb/100000;h2[8]='0'+fb/10000%10;h2[9]='0'+fb/1000%10;h2[10]='0'+fb/100%10;h2[11]='0'+fb/10%10;h2[12]='0'+fb%10;if(h==2)if(Sel_ok==1) h2[15]='*';else h2[15]='-';else h2[15]=' ';ph_disp=n*100*11.25;h3[6]='0'+ph_disp/10000;h3[7]='0'+ph_disp/1000%10;h3[8]='0'+ph_disp/100%10;h3[10]='0'+ph_disp/10%10;h3[11]='0'+ph_disp%10;if(h==3)if(Sel_ok==1) h3[15]='*';else h3[15]='-';else h3[15]=' ';}void LCD_Display()//12864整屏显示{change();DisplayListChar(0,0,h1);DisplayListChar(0,1,h2);DisplayListChar(0,2,h3);DisplayListChar(0,3,h4);}void H_sel()//行参数选择{switch(IRcord[2]){case 0x1b:h--;if(h<1) h=3;H_ok=1;break;//ch+ case 0x1f:h++;if(h>3) h=1;H_ok=1;break;//ch- default:break;}irpro_ok=0;}void Step_sel(void)//步进输入{switch(IRcord[2])//判断红外遥控用户码值{case 0x1a://*********************************vol+if(h==3) {ph+=8;if(ph>0xf8)ph=0;n++;if(n>31)n=0;Step_ok=1;}elseif(h==1){ph=0;n=0;fa++;if(fa>999999) fa=999999;Step_ok=1;}if(h==2){ph=0;n=0;fb++;if(fb>999999) fb=999999;Step_ok=1;}break;case 0x1e://**********************************vol-if(h==3) {ph-=8;if(ph<0)ph=0xf8;n--;if(n<0)n=31;Step_ok=1;}elseif(h==1){ph=0;n=0;fa--;if(fa<0) fa=0;Step_ok=1;}if(h==2){ph=0;n=0;fb--;if(fb<0) fb=0;Step_ok=1;}break;default:break;}irpro_ok=0;}void Num_sel()//数字输入,频率可直接数字输入,相位步进输入{switch(IRcord[2])//判断用户码值{case 0x01://****************************************1f=f*10+1;if(f>999999) f=0;Num_ok=0;Sel_ok=0;if(h==1){fa=f;ph=0;n=0;LCD_Display();}if(h==2){fb=f;ph=0;n=0;LCD_Display();}//if(h==3){if(f>255) f=0;ph=0;LCD_Display();}break;case 0x02://************************************2f=f*10+2;if(f>999999) f=0;Num_ok=0;Sel_ok=0;if(h==1){fa=f;ph=0;n=0;LCD_Display();}if(h==2){fb=f;ph=0;n=0;LCD_Display();}//if(h==3){if(f>255) f=0;ph=f;LCD_Display();}break;case 0x03://************************************3f=f*10+3;if(f>999999) f=0;Num_ok=0;Sel_ok=1;if(h==1){fa=f;ph=0;n=0;LCD_Display();}if(h==2){fb=f;ph=0;n=0;LCD_Display();}//if(h==3){if(f>255) f=0;ph=f;LCD_Display();} break;case 0x04://************************************4 f=f*10+4;if(f>999999) f=0;Num_ok=0;Sel_ok=0;if(h==1){fa=f;ph=0;n=0;LCD_Display();}if(h==2){fb=f;ph=0;n=0;LCD_Display();}//if(h==3){if(f>255) f=0;ph=f;LCD_Display();} break;case 0x05://************************************5 f=f*10+5;if(f>999999) f=0;Num_ok=0;Sel_ok=0;if(h==1){fa=f;ph=0;n=0;LCD_Display();}if(h==2){fb=f;ph=0;n=0;LCD_Display();}//if(h==3){if(f>255) f=0;ph=f;LCD_Display();} break;case 0x06://************************************6 f=f*10+6;if(f>999999) f=0;Num_ok=0;Sel_ok=0;if(h==1){fa=f;ph=0;n=0;LCD_Display();}if(h==2){fb=f;ph=0;n=0;LCD_Display();}//if(h==3){if(f>255) f=0;ph=f;LCD_Display();} break;case 0x07://************************************7 f=f*10+7;if(f>999999) f=0;Num_ok=0;Sel_ok=0;if(h==1){fa=f;ph=0;n=0;LCD_Display();}if(h==2){fb=f;ph=0;n=0;LCD_Display();}//if(h==3){if(f>255) f=0;ph=f;LCD_Display();} break;case 0x08://************************************8 f=f*10+8;if(f>999999) f=0;Num_ok=0;Sel_ok=0;if(h==1){fa=f;ph=0;n=0;LCD_Display();}if(h==2){fb=f;ph=0;n=0;LCD_Display();}//if(h==3){if(f>255) f=0;ph=f;LCD_Display();} break;case 0x09://************************************9 f=f*10+9;if(f>999999) f=0;Num_ok=0;Sel_ok=0;if(h==1){fa=f;ph=0;n=0;LCD_Display();}if(h==2){fb=f;ph=0;n=0;LCD_Display();}//if(h==3){if(f>255) f=0;ph=f;LCD_Display();} break;case 0x00://************************************0f=f*10;if(f>999999) f=0;Num_ok=0;Sel_ok=0;if(h==1){fa=f;ph=0;n=0;LCD_Display();}if(h==2){fb=f;ph=0;n=0;LCD_Display();}//if(h==3){if(f>255) f=0;ph=f;LCD_Display();} break;case 0x5c:Num_ok=1;break;//********************确定case 0x57:f=f/10;if(f>999999) f=0;//***************取消Num_ok=0;Sel_ok=0;if(h==1){fa=f;ph=0;n=0;LCD_Display();}if(h==2){fb=f;ph=0;n=0;LCD_Display();}break;default:break;}irpro_ok=0;}void Num_process()//数字输入处理{if(Num_ok==1){AD9850_ok=0;Reset_AD9850();Write_AD9850(ph,0x00,fa,fb);Sel_ok=1;f=0;AD9850_ok=1;}}void Step_process()//步进输入处理{if(Step_ok==1){AD9850_ok=0;Reset_AD9850();Write_AD9850(ph,0x00,fa,fb);AD9850_ok=1;}}void IR_process(void)//红外综合处理{if(irok)//如果红外信号接收好了进行红外数据处理{Ircordpro();irok=0;}if(irpro_ok)//如果红外数据处理好后进行其他工作处理{H_sel();Step_sel();Num_sel();}}void main(){Port_init();//端口初始化TIM0init();//定时器0初始化EX0init();//外部中断0初始化LCDInit();//12864初始化LCDClear();//12864清屏LCDClear();LCD_Display();//12864显示初始内容Reset_AD9850();//AD9850复位Reset_AD9850();//AD9850复位Write_AD9850(ph,0x00,fa,fb);//AD9850写初始数据delay_1ms(10);while(1){if( (Num_ok||Step_ok)||H_ok){LCD_Display();H_ok=0;Num_ok=0;Step_ok=0;}/*只有在各项输入选择完成后才更新显示内容避免12864因写数据时受其他影响而白屏*/IR_process();Num_process();Step_process();}}/*****************************************************12864显示部分(12864.h)*****************************************************/#include <reg52.h>sfr P4=0xe8;//STC89C52RC(TQFP封装)有P4口,入口地址为0xe8sbit LCD_RS = P4^0;sbit LCD_RW = P4^1;sbit LCD_E = P4^2;sbit LCD_PSB = P3^7;#define LCD_Data P2//12864数据口,并行传送#define BUSY 0x80 //12864忙信号ReadStatusLCD()//读12864状态{LCD_RS = 0;LCD_RW = 1;LCD_E = 0;LCD_Data = 0xFF;LCD_E = 1;while (LCD_Data & BUSY);LCD_E = 0;return(LCD_Data);}void WriteCommandLCD(unsigned char WCLCD,BusyC)//写指令{if (BusyC) ReadStatusLCD();LCD_Data = WCLCD;LCD_RS = 0;LCD_RW = 0;LCD_E = 1;LCD_E = 1;LCD_E = 1;LCD_E = 0;}void WriteDataLCD(unsigned char WDLCD)//写数据{ReadStatusLCD(); //busy testLCD_RS = 1;LCD_RW = 0;LCD_Data = WDLCD;LCD_E = 1;LCD_E = 0;LCD_E = 0;LCD_E = 1;}void LCDClear(void)//清屏{WriteCommandLCD(0x01,1); //显示清屏WriteCommandLCD(0x34,1); //显示光标移动设置WriteCommandLCD(0x30,1); //显示开及光标设置}//显示一行字符,起始坐标为(X,Y)void DisplayListChar(unsigned char X, unsigned char Y, unsigned char *DData) {switch(Y){case 0:Y =0X80;break; //根据行数来选择相应地址case 1:Y=0X90;break;case 2:Y=0X88;break;case 3:Y=0X98;break;}WriteCommandLCD( Y+X , 1); //这里不检测忙信号,发送地址码X = X*2;Y = 0;while ( DData[Y] != 0 ) //若到达字符串尾则退出{if (X <= 0x0F) //X坐标应小于0xF{WriteDataLCD(DData[Y]);X++;Y++;//Delay5Ms();}else break;}}/****************************************************38KHz红外接收头部分(IR.h)东芝TC9012编码****************************************************/#include<reg52.h>#include<stdio.h>#include<intrins.h>#define TURE 1#define FALSE 0#define uchar unsigned char#define uint unsigned intsbit IR=P3^2; //红外接口,使用外部中断0unsigned char irtime;//红外用全局变量bit irok,irpro_ok;//红外接收成功标志,红外处理完毕标志unsigned char IRcord[4];32位数据码,共4个字节unsigned char irdata[33];//每个电平的持续时间void Ir_work(void);void Ircordpro(void);void tim0_isr (void) interrupt 1 using 1//定时器0中断服务函数{irtime++; //用于计数2个下降沿之间的时间}void ex0_isr (void) interrupt 0 using 0//外部中断0服务函数{static unsigned char i; //接收红外信号处理static bit startflag; //是否开始处理标志位if(startflag){if(irtime<63&&irtime>=33)//引导码TC9012的头码,9ms+4.5msi=0;irdata[i]=irtime;//存储每个电平的持续时间,用于以后判断是0还是1irtime=0;i++;if(i==33){irok=1;i=0;}}else{irtime=0;startflag=1;}}void TIM0init(void)//定时器0初始化{TMOD=0x02;//定时器0工作方式2,TH0是重装值,TL0是初值TH0=0x00; //重载值TL0=0x00; //初始化值ET0=1; //开中断TR0=1;}void EX0init(void){IT0 = 1; //外部中断0下降沿触发EX0 = 1; //使能外部中断EA = 1; //开总中断}void Ircordpro(void)//红外码值处理函数{unsigned char i, j, k;unsigned char cord,value;k=1;for(i=0;i<4;i++) //处理4个字节{for(j=1;j<=8;j++) //处理1个字节8位{cord=irdata[k];if(cord>7)//大于7值为1,和晶振有关系,12M{value=value|0x80;}else{value=value;}if(j<8){value=value>>1;}k++;}IRcord[i]=value;value=0;} irpro_ok=1;//处理完毕标志位置1}void Port_init()//端口初始化{P0=0xff;P1=0xff;P2=0xff;P3=0xff;}/***********************************************AD9850部分(AD9850.h)时钟源为12M有源晶振***********************************************/#include <reg52.h>#include <intrins.h>#define uchar unsigned char#define uint unsigned int#define Data__A P0//数据口,并行模式#define Data__B P1sbit WCLK_A= P3^0;//控制字装载时钟sbit FQUD_A= P3^1;//频率更新sbit REST_A= P3^3;//复位sbit WCLK_B= P3^4;sbit FQUD_B= P3^5;sbit REST_B= P3^6;/********************************AD9850的40位控制字(5字节)第一字节:高5位为相位控制字,低三位为电源和其他控制字,低3位一般取000********************************/uchar word_a[5]={0x00,0x00,0x00,0x00,0x00};uchar word_b[5]={0x00,0x00,0x00,0x00,0x00};void CHF_A(unsigned long int a)//将想要的频率和相位转为40位控制字{unsigned long int j;j=357.9139413*a; //a是A通道要输出的频率值,单位Hz,12M除以2的32次方等于357.9139413word_a[1]=j>>24;word_a[2]=j>>16;word_a[3]=j>>8;word_a[4]=j;}void CHF_B(unsigned long int b){unsigned long int k;k=357.9139413*b; //b是B通道要输出的频率值,单位Hzword_b[1]=k>>24;word_b[2]=k>>16;word_b[3]=k>>8;word_b[4]=k;}void delay_1ms(uint t){uint i,j;for(i=0;i<t;i++)for(j=0;j<120;j++);}void Reset_AD9850()//复位,并行模式{WCLK_A=0;WCLK_B=0;FQUD_A=0;FQUD_B=0;REST_A=0;REST_B=0;REST_A=1;REST_B=1;REST_A=0;REST_B=0;}//以并行方式同时向两个AD9850写控制字void Write_AD9850(uchar PH_A,uchar PH_B,unsigned long int FQ_A,unsigned long int FQ_B) {uint i;REST_A=1;REST_B=1;delay_1ms(100);WCLK_A=0;WCLK_B=0;FQUD_A=0;FQUD_B=0;REST_A=1;REST_B=1;CHF_A(FQ_A);CHF_B(FQ_B);word_a[0]=PH_A;word_b[0]=PH_B;for(i=0;i<5;i++){Data__A=word_a[i];Data__B=word_b[i];WCLK_A=1;_nop_();WCLK_B=1;_nop_();WCLK_A=0;_nop_();WCLK_B=0;_nop_();}FQUD_A=0;_nop_();FQUD_B=0;_nop_();FQUD_A=1;_nop_();FQUD_B=1;_nop_();Data__A=0x00;Data__B=0x00;}。

12864显示原理以及其使用方法

12864显示原理以及其使用方法

单色液晶屏:
12864显示原理以及其使用方法
液晶简介:
液晶它是一种在一定的温度范围内呈现既不同于固态液态又不同于气态的一种特殊物质态,它既具有各向异性的晶体所特有的双折射性,又具有着液体的流动性液晶显示器件(英文的简写名是LCD),就是利用了液晶态物质的液晶分子排列状态在电场之中改变而调制外界光的被动型显示器件。

点阵式的图形液晶显示屏是 LCD 之中的一种能够动态显示出图形汉字,以及各种符号信息的产品,它为各种电子产品提供了很友好的人机界面,点阵图形液晶屏的主要特点(这些特点其实也就是LCD 的特点):微功耗、工作电压低、可视面积大、体积小、无电磁辐射、数字接口、寿命长等等特点。

组成。

可以完成图形的显示,也可以显示出8×4 个(16×16 点阵)汉字或者显示16×4个(8×16 点阵)的ASCII 码。

一般分为两种,带字库的以及不带字库的。

不带字库的LCD则需要自己提供字库字模,此时就可以根据自己个人的喜好去设置各种字体的显示风格,设计上比较灵活。

带字库的LCD则提供字库字模,但是只能够显示出GB2312的宋体。

各有其优缺点,可以根据不同的应用场景灵活选择。

其液晶模块的原理图如下图所示。

12864LCD的点阵图形液晶模块的原理框图。

液晶显示12864程序(调试通过)

液晶显示12864程序(调试通过)
0x00,0x00,0x07,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x1F,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x38,0x0E,0x01,0xFF,0x1F,0xF8,0x00,0x07,0xFE,0x03,0xF8,0x00,0xFF,0xFF,0x00,
0x00,0x3C,0x06,0x01,0xFC,0x1F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0xFF,0xFF,0xC0,0x00,0x00,0x0F,0xFF,0xFF,0xF0,0x00,0x00,0x1F,
0xFF,0xFF,0xFE,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0x00,0x00,0x7F,0xFF,0xF8,0x07,0x80,
0x00,0x00,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x7F,0xF8,0x07,0x80,0x3F,0x01,0xFF,0xF0,0x07,0xE0,0x00,0x07,0xFF,0xF0,0x03,0xF0,
0x00,0x1F,0xFF,0xE0,0x01,0xFF,0x03,0xFF,0xFF,0xC0,0x01,0xFF,0xFF,0xFF,0xFF,0xC0,

无杂点 12864 显示AD

无杂点 12864 显示AD

无杂点 12864 显示AD.txt让人想念而死,是谋杀的至高境界,就连法医也鉴定不出死因。

#include <iom16v.h>#include <macros.h>#include <string.h>#include<MATH.H>#define uchar unsigned char#define uint unsigned int#pragma interrupt_handler ad_handler:15uint addata,flag;uchar i,y;#define RS (1<<0)#define RW (1<<1)#define EN (1<<2)void Write_com(unsigned char WCLCM);void Write_data(unsigned char WDLCM);void img_disp(__flash unsigned char *img){uchar i,j;for(j=0;j<32;j++){for(i=0;i<8;i++){Write_com(0x34); //扩充指令集,关绘图Write_com(0x80+j); //先将垂直坐标(Y)写入绘图RAM地址Write_com(0x80+i); //再将水平坐标(X)写入绘图RAM地址Write_com(0x30); //打开基本指令集Write_data(img[j*16+i*2]); //将D15--D8写入到RAM,Write_data(img[j*16+i*2+1]); //将D7--D0写入到RAM}}for(j=32;j<64;j++) //下半屏{for(i=0;i<8;i++){Write_com(0x34); //扩充指令集,关绘图Write_com(0x80+j-32); //先将垂直坐标(Y)写入绘图RAM地址Write_com(0x88+i); //再将水平坐标(X)写入绘图RAM地址Write_com(0x30); //打开基本指令集Write_data(img[j*16+i*2]); //将D15--D8写入到RAM,Write_data(img[j*16+i*2+1]); //将D7--D0写入到RAM}}Write_com(0x36); //打开绘图显示}//延时函数void s_ms(uint ms){for(;ms>1;ms--);}//此处定义字符串//写数据void Write_data(unsigned char WDLCM) {s_ms(5);PORTD|=RS; //RS=1s_ms(5);PORTD&=~RW; //RW=0s_ms(5);PORTD|=EN; //EN=1s_ms(5);PORTB=WDLCM; //输出数据s_ms(5);PORTD&=~EN; //EN=0s_ms(5);}//写指令void Write_com(unsigned char WCLCM) {s_ms(5);PORTD&=~RS; //RS=0s_ms(5);PORTD&=~RW; //RW=0s_ms(5);PORTD|=EN; //EN=1s_ms(5);PORTB=WCLCM; //输出指令s_ms(5);PORTD&=~EN; //EN=0s_ms(5);}uchar read_data(void){uchar lcd_data;PORTB=0xff;DDRB=0x00;PORTD|=RW;PORTD|=RS;PORTD|=EN;s_ms(10);lcd_data=PINB;s_ms(10);PORTD&=~EN;DDRB=0xff;return(lcd_data) ;}void point(uchar x,uchar y,uchar flag) {uchar x_Dyte,x_byte;uchar y_Dyte,y_byte;uchar GDRAM_hbit,GDRAM_lbit;Write_com(0x36);x_Dyte=x/16;x_byte=x&0x0f;y_Dyte=y/32;y_byte=y&0x1f;Write_com(0x80+y_byte);Write_com(0x80+x_Dyte+8*y_Dyte);read_data();GDRAM_hbit=read_data();GDRAM_lbit=read_data();s_ms(5);Write_com(0x80+y_byte); //设定行地址(y坐标)Write_com(0x80+x_Dyte+8*y_Dyte); //设定列地址(x坐标),并通过8*y_Dyte选定上下屏s_ms(5);if(x_byte<8){if(flag==1)Write_data(GDRAM_hbit|(0x01<<(7-x_byte)));elseWrite_data(GDRAM_hbit&(~(0x01<<(7-x_byte))));Write_data(GDRAM_lbit);}else{Write_data(GDRAM_hbit);if(flag==1)Write_data(GDRAM_lbit|(0x01<<(15-x_byte)));elseWrite_data(GDRAM_lbit&(~(0x01<<(15-x_byte))));}Write_com(0x30);}//LCM初始化void LCMInit(void){Write_com(0x30); //三次显示模式设置,不检测忙信号s_ms(5);Write_com(0x30);s_ms(5);//Write_com(0x30);//s_ms(10);Write_com(0x30); //显示模式设置,开始要求每次检测忙信号Write_com(0x08); //关闭显示Write_com(0x01); //显示清屏Write_com(0x06); //显示光标移动设置Write_com(0x0C); //显示开及光标设置}void clear(uchar dat){uchar i,j,k;uchar addr=0x80;for(i=0;i<2;i++){for(j=0;j<32;j++){for(k=0;k<8;k++){Write_com(0x36);Write_com(0x80+j);Write_com(addr+k);Write_data(dat);Write_data(dat);}}addr=0x88;}Write_com(0x36);Write_com(0x30);void ad_handler(void){addata=ADCH;//PORTB=~(addata); //取反用LED显示ADCSRA|=BIT(ADSC); //启动下一次转换 ADCSR状态寄存器 ADSC模数转换启动位//ADCSR|=(1< }}//主函数void main(void){//端口初始化uchar table[127]={0};int b;PORTA=0; //无上拉DDRA=0; //设置PA口为输入DDRD=0xff;PORTD=0xff;DDRB=0xff;PORTB=0xff;s_ms(10);LCMInit(); //LCM初始化 //液晶初始化s_ms(10);clear(0x00);for(i=0;i<128;i++){point(i,58,1);}for(i=0;i<64;i++){point(10,i,1);}ADMUX=0x60; //基准AVCC,左对齐选择第2通道加入ADCSRA=0xCE; //采用单次转换模式,64分频ADCSRA|=BIT(ADSC); //启动一次哑转换SREG=0x80;//开中断while(1){for(i=12;i<128;i++){ADCSRA|=BIT(ADSC); //启动一次转换b=54-addata/4;point(i,b,1);table[i]=b;s_ms(10000);}for(i=12;i<128;i++){point(i,table[i],0);}}/*for(i=12;i<128;i++){ADCSRA|=BIT(ADSC); //启动一次转换s_ms(10);point(i,54-addata/4,1);table[i]=54-addata/4;s_ms(1000);}while(1){for(i=12;i<128;i++){point(i,table[i],0);ADCSRA|=BIT(ADSC); //启动一次转换s_ms(10);point(i,54-addata/4,1);table[i]=54-addata/4;s_ms(1000);}}*/}。

单片机控制AD603程序:12864显示

单片机控制AD603程序:12864显示

#include<reg52.h>#include <string.h>#define PCF8591 0x90 //PCF8591 地址#define uchar unsigned char#define uint unsigned int#define NOP() _nop_() /* 定义空指令*/#define _Nop() _nop_() /*定义空指令*/uchar code IC_DAT[];sbit RS = P2^5;sbit WRD = P2^6;sbit E = P2^7;sbit RES = P2^4;sbit PSB = P2^3;sbit P2_0=P2^0;sbit P2_1=P2^1;sbit P2_2=P2^2;sbit SDA=P3^6; //I2C 数据sbit SCL=P3^7; //I2C 时钟bit ack; /*应答标志位*/sbit KEY1 = P3^2;sbit KEY2 = P3^3;sbit KEY3 = P3^4;sbit KEY4 = P3^5;void TransferData(char data1,bit DI);void display(void);void delayms(uint n);void DisplayLine(uchar line1,uchar line2);void delay(uint m);uchar code IC_DAT[]={"show_mesg1(j);""show_mesg2(v);"" 单片机开发板"" 东流电子"};/*******************************************************************起动总线函数函数原型: void Start_I2c();功能: 启动I2C总线,即发送I2C起始条件.********************************************************************/ void Start_I2c(){SDA=1; /*发送起始条件的数据信号*/_Nop();SCL=1;_Nop(); /*起始条件建立时间大于4.7us,延时*/_Nop();_Nop();_Nop();_Nop();SDA=0; /*发送起始信号*/_Nop(); /* 起始条件锁定时间大于4μs*/_Nop();_Nop();_Nop();_Nop();SCL=0; /*钳住I2C总线,准备发送或接收数据*/_Nop();_Nop();}/*******************************************************************结束总线函数函数原型: void Stop_I2c();功能: 结束I2C总线,即发送I2C结束条件.********************************************************************/ void Stop_I2c(){SDA=0; /*发送结束条件的数据信号*/_Nop(); /*发送结束条件的时钟信号*/SCL=1; /*结束条件建立时间大于4μs*/_Nop();_Nop();_Nop();_Nop();_Nop();SDA=1; /*发送I2C总线结束信号*/_Nop();_Nop();_Nop();_Nop();}/*******************************************************************字节数据发送函数函数原型: void SendByte(UCHAR c);功能: 将数据c发送出去,可以是地址,也可以是数据,发完后等待应答,并对此状态位进行操作.(不应答或非应答都使ack=0)发送数据正常,ack=1; ack=0表示被控器无应答或损坏。

12864液晶屏显示时间,加按键,加界面切换

12864液晶屏显示时间,加按键,加界面切换

/////////////////////////////////////////////////////程序编写人:小艾//程序编写时间:2012-5-16//程序实现的功能:12864的显示,汇编//////////////////////////////////////////////////////// AIXING EQU 41HAIXING1 EQU 42HSECOND EQU 43HMINUTE EQU 44HHOUR EQU 45HMINUTE1 EQU 46HHOUR1 EQU 47HMINUTE2 EQU 48HHOUR2 EQU 49HMINUTE3 EQU 4AHHOUR3 EQU 4BHMINUTE4 EQU 4CHHOUR4 EQU 4DHCSA EQU P3.2CSB EQU P3.3RS EQU P3.6RW EQU P3.5E EQU P3.4OUTPUT EQU P2COM EQU 2CHDAT EQU 2DHCODES EQU 2Ehcolumn EQU 24Hpagef EQU 25hcpage EQU 26Hccolumn E QU 27Hcolumn2 EQU 28Hpagef2 EQU 29hcpage2 EQU 2aHccolumn2 EQU 2bHCOUNT EQU 60HCOUNT1 EQU 61H//COUNT2 EQU 62H//COUNT3 EQU 63HCOUNT4 EQU 64HCOUNT5 EQU 65Hcolumn1 EQU 30H pagef1 EQU 31h cpage1 EQU 32H ccolumn1 EQU 33H column3 EQU 34H pagef3 EQU 35h cpage3 EQU 36H ccolumn3 EQU 37HSHUJI1 EQU 50H SHUJI2 EQU 51H SHUJI3 EQU 52H SHUJI4 EQU 53H SHUJI5 EQU 54H SHUJI6 EQU 55H SHUJI7 EQU 56H SHUJI8 EQU 57H SHUJI9 EQU 58H SHUJI10 EQU 59H SHUJI11 EQU 5AH SHUJI12 EQU 5BH SHUJI13 EQU 5CH SHUJI14 EQU 5DH SHUJI15 EQU 5EH SHUJI16 EQU 38H SHUJI17 EQU 39H SHUJI18 EQU 3AH SHUJI19 EQU 3BH SHUJI20 EQU 3CH SHUJI21 EQU 3DH SHUJI22 EQU 3EHKEY1 BIT P1.1 KEY2 BIT P1.2 KEY3 BIT P1.3 KEY4 BIT P1.4 KEY5 BIT P1.5 KEY6 BIT P1.6 BT0 BIT 20H.0 BT1 BIT 20H.1 BT2 BIT 20H.2 BT3 BIT 20H.3 BT4 BIT 20H.4 BT5 BIT 20H.5BT6 BIT 20H.6BT7 BIT 20H.7BT8 BIT 21H.0BT9 BIT 21H.1BT10 BIT 21H.2BT11 BIT 21H.3BT12 BIT 21H.4BT13 BIT 21H.5/////////////////////////////////////////////////ORG 0000HLJMP STARTORG 000BHLJMP INTP0ORG 0030H;*********************************************主程序开始START: MOV TMOD,#01HMOV TH0,#(65536-50000) / 256MOV TL0,#(65536-50000) MOD 256SETB EASETB ET0SETB TR0LCALL CLEARLCALL INT ;调用初始化子程序/////////////////////////////////////////////////////MAIN: LCALL KEYSCAN1JB BT7,MAIN1MAIN4: LCALL CLEAR ;调用清屏子程序LCALL DISPLAY1LCALL KKKLCALL DISPLAYLCALL DISPLAY5LCALL DISPLAY6MAIN2: LCALL KKKLCALL DISPLAYLCALL KEYSCAN1JB BT7,MAIN1LJMP MAIN2MAIN1: LCALL CLEAR ;调用清屏子程序MAIN3: LCALL DISPLAY2LCALL DISPLAY3LCALL KEYSCAN1JB BT7,MAIN3LJMP MAIN4////////////////////////////////////////////////////////DISPLAY3:LCALL CHULI1MOV A,COUNT4CJNE A,#0,DISPLAY4RET//////////////////////////////////////////////////// DISPLAY4:CLR COUNT1CLR ALCALL CHULI1MOV A,COUNT4CJNE A,#1,PLAY1LCALL CLEARQQ1: LCALL KKKLCALL KEYSCANLCALL KEYCHULI1LCALL KEYCHULI11LCALL KEYCHULI2LCALL KEYCHULI21LCALL DISPLAYMOV COM,#00HLCALL PRR0LCALL PRM0LCALL CHULI1MOV A,COUNT4CJNE A,#1,PLAY1AJMP QQ1PLAY1: CLR AMOV COUNT1,#0MOV A,COUNT4CJNE A,#2,PLAY2LCALL CLEARQQ2: CLR ALCALL CHULI2MOV A,COUNT5CJNE A,#0,CHULCALL KEYSCANLCALL KEYCHU1LCALL KEYCHU11LCALL KEYCHU5LCALL KEYCHU51LCALL DISPLAY5MOV COM,#00HLCALL PRR0LCALL PRM0LCALL CHULI1CLR AMOV A,COUNT4CJNE A,#2,PLAY2LJMP QQ2 CHU: CLR AMOV A,COUNT5CJNE A,#1,PLAY3LCALL KEYSCANLCALL KEYCHU2LCALL KEYCHU21LCALL KEYCHU6LCALL KEYCHU61LCALL DISPLAY5MOV COM,#00HLCALL PRR0LCALL PRM0LCALL CHULI1CLR AMOV A,COUNT4CJNE A,#2,PLAY2LJMP QQ2///////////////////////////////////////////////// PLAY2: MOV COUNT5,#0CLR AMOV A,COUNT4CJNE A,#3,PLAY3LCALL CLEARQQ3: CLR ALCALL CHULI2MOV A,COUNT5CJNE A,#0,CHU1LCALL KEYSCANLCALL KEYCHU3LCALL KEYCHU31LCALL KEYCHU7LCALL KEYCHU71LCALL DISPLAY6CLR ALCALL CHULI1MOV A,COUNT4CJNE A,#3,PLAY2LJMP QQ3CHU1: CLR AMOV A,COUNT5CJNE A,#1,PLAY3LCALL KEYSCANLCALL KEYCHU4LCALL KEYCHU41LCALL KEYCHU8LCALL KEYCHU81LCALL DISPLAY6LCALL CHULI1CLR AMOV A,COUNT4CJNE A,#3,PLAY3LJMP QQ3PLAY3: LCALL CLEARMOV COUNT4,#0MOV COUNT5,#0RET////////////////显示“菜”/////////////////////////////////// DISPLAY2:MOV CODES,#0MOV column1,#16MOV pagef1,#0MOV CODES,#14CALL writeleft1///////////////////显示“单”////////////////////////////// MOV CODES,#0MOV column3,#00MOV pagef3,#0MOV CODES,#15CALL writeright1/////////////////显示“时”//////////////////////////////MOV CODES,#0MOV column1,#16MOV pagef1,#2MOV CODES,#16CALL writeleft1/////////////////显示“钟”/////////////////////////////// MOV CODES,#0MOV column1,#32MOV pagef1,#2MOV CODES,#17CALL writeleft1/////////////////显示“设”//////////////////////////////MOV column1,#48MOV pagef1,#2MOV CODES,#22CALL writeleft1/////////////////显示“定”/////////////////////////////// MOV CODES,#0MOV column3,#00MOV pagef3,#2MOV CODES,#23CALL writeright1/////////////////显示“开”////////////////////////////// MOV CODES,#0MOV column1,#16MOV pagef1,#4MOV CODES,#18CALL writeleft1/////////////////显示“关”/////////////////////////////// MOV CODES,#0MOV column1,#32MOV pagef1,#4MOV CODES,#19CALL writeleft1/////////////////显示“设”////////////////////////////// MOV CODES,#0MOV column1,#48MOV pagef1,#4MOV CODES,#22CALL writeleft1/////////////////显示“定”/////////////////////////////// MOV CODES,#0MOV column3,#00MOV pagef3,#4MOV CODES,#23CALL writeright1/////////////////显示“调”////////////////////////////// MOV CODES,#0MOV column1,#16MOV pagef1,#6MOV CODES,#20CALL writeleft1/////////////////显示“光”/////////////////////////////// MOV CODES,#0MOV pagef1,#6MOV CODES,#21CALL writeleft1/////////////////显示“设”//////////////////////////////MOV CODES,#0MOV column1,#48MOV pagef1,#6MOV CODES,#22CALL writeleft1/////////////////显示“定”///////////////////////////////MOV CODES,#0MOV column3,#00MOV pagef3,#6MOV CODES,#23CALL writeright1LJMP BB///////////////////显示“星”///////////////////////////// DISPLAY1:MOV CODES,#0MOV column1,#00MOV pagef1,#0MOV CODES,#0lcall writeleft1//////////////////显示“梦”////////////////////////////////// MOV CODES,#0MOV column1,#16MOV pagef1,#0MOV CODES,#1CALL writeleft1//////////////////显示“奕”/////////////////////////////MOV CODES,#0MOV column1,#32MOV pagef1,#0MOV CODES,#2CALL writeleft1////////////////显示“缘”/////////////////////////////MOV CODES,#0MOV column1,#48MOV pagef1,#0MOV CODES,#3CALL writeleft1LJMP BB/////////////////显示“time”////////////////////////////KKK: MOV CODES,#0MOV column,#00MOV pagef,#2MOV CODES,#13CALL writeleftMOV CODES,#0MOV column,#8MOV pagef,#2MOV CODES,#14CALL writeleftMOV CODES,#0MOV column,#16MOV pagef,#2MOV CODES,#15CALL writeleftMOV CODES,#0MOV column,#24MOV pagef,#2MOV CODES,#16CALL writeleftMOV CODES,#0MOV column,#32MOV pagef,#2 ;显示:MOV CODES,#11CALL writeleftRET///////////////“L1开”///////////////////////////////////// DISPLAY5: MOV C ODES,#0MOV column1,#00MOV pagef1,#4MOV CODES,#11CALL writeleft1MOV CODES,#0MOV column,#8MOV pagef,#4MOV CODES,#1CALL writeleftMOV CODES,#0MOV column,#16MOV pagef,#4 ;显示:MOV CODES,#11CALL writeleftMOV CODES,#0MOV SHUJI7,#0CLR AMOV A,MINUTE1MOV B,#10DIV ABMOV A,BMOV SHUJI7,AMOV column,#56MOV pagef,#4MOV CODES,SHUJI7 ;分低位CALL writeleftMOV CODES,#0MOV SHUJI8,#0MOV CODES,#0CLR AMOV A,MINUTE1MOV B,#10DIV ABMOV SHUJI8,AMOV column,#48MOV pagef,#4MOV CODES,SHUJI8 ;分高位CALL writeleftMOV CODES,#0MOV column,#40MOV pagef,#4 ;显示:MOV CODES,#11CALL writeleftMOV CODES,#0MOV SHUJI9,#0CLR AMOV A,HOUR1MOV B,#10DIV ABMOV A,BMOV SHUJI9,Amov column,#32mov pagef,#4MOV CODES,SHUJI9 ;时低位lcall writeleftMOV CODES,#0MOV SHUJI10,#0MOV CODES,#0CLR AMOV A,HOUR1MOV B,#10DIV ABMOV SHUJI10,AMOV column,#24MOV pagef,#4MOV CODES,SHUJI10 ;时高位CALL writeleft///////////////L1关/////////////////////////MOV CODES,#0MOV column3,#48MOV pagef3,#4MOV CODES,#10CALL writeright1MOV CODES,#0MOV SHUJI11,#0CLR AMOV A,MINUTE2MOV B,#10DIV ABMOV A,BMOV SHUJI11,AMOV column2,#40MOV pagef2,#4MOV CODES,SHUJI11 ;分低位CALL writerightMOV CODES,#0MOV SHUJI12,#0MOV CODES,#0CLR AMOV A,MINUTE2MOV B,#10DIV ABMOV SHUJI12,AMOV column2,#32MOV pagef2,#4MOV CODES,SHUJI12 ;分高位CALL writerightMOV CODES,#0MOV column2,#24MOV pagef2,#4 ;显示:MOV CODES,#11CALL writerightMOV CODES,#0MOV SHUJI13,#0CLR AMOV A,HOUR2MOV B,#10DIV ABMOV A,BMOV SHUJI13,Amov column2,#16mov pagef2,#4MOV CODES,SHUJI13 ;时低位CALL writerightMOV CODES,#0MOV SHUJI14,#0MOV CODES,#0CLR AMOV A,HOUR2MOV B,#10DIV ABMOV SHUJI14,AMOV column2,#8MOV pagef2,#4MOV CODES,SHUJI14 ;时高位CALL writerightMOV CODES,#0MOV column2,#00MOV pagef2,#4MOV CODES,#12 ;时高位CALL writerightLJMP BB///////////////“L2开”/////////////////////////////////////DISPLAY6: MOV CODES,#0MOV column1,#00MOV pagef1,#6MOV CODES,#11CALL writeleft1MOV CODES,#0MOV column,#8MOV pagef,#6MOV CODES,#2CALL writeleftMOV CODES,#0MOV column,#16MOV pagef,#6 ;显示:MOV CODES,#11CALL writeleftMOV CODES,#0MOV SHUJI15,#0CLR AMOV A,MINUTE3MOV B,#10DIV ABMOV A,BMOV SHUJI15,AMOV column,#56MOV pagef,#6MOV CODES,SHUJI15 ;分低位CALL writeleftMOV SHUJI16,#0MOV CODES,#0CLR AMOV A,MINUTE3MOV B,#10DIV ABMOV SHUJI16,AMOV column,#48MOV pagef,#6MOV CODES,SHUJI16 ;分高位CALL writeleftMOV CODES,#0MOV column,#40MOV pagef,#6 ;显示:MOV CODES,#11CALL writeleftMOV CODES,#0MOV SHUJI17,#0CLR AMOV A,HOUR3MOV B,#10DIV ABMOV A,BMOV SHUJI17,Amov column,#32mov pagef,#6MOV CODES,SHUJI17 ;时低位lcall writeleftMOV SHUJI8,#0MOV CODES,#0CLR AMOV A,HOUR3MOV B,#10DIV ABMOV SHUJI18,AMOV column,#24MOV pagef,#6MOV CODES,SHUJI18 ;时高位CALL writeleft///////////////L2关/////////////////////////MOV CODES,#0MOV column3,#48MOV pagef3,#6MOV CODES,#9CALL writeright1MOV CODES,#0MOV SHUJI19,#0CLR AMOV A,MINUTE4MOV B,#10DIV ABMOV A,BMOV SHUJI19,AMOV column2,#40MOV pagef2,#6MOV CODES,SHUJI19 ;分低位CALL writerightMOV SHUJI20,#0MOV CODES,#0CLR AMOV A,MINUTE4MOV B,#10DIV ABMOV SHUJI20,AMOV column2,#32MOV pagef2,#6MOV CODES,SHUJI20 ;分高位CALL writerightMOV CODES,#0MOV column2,#24MOV pagef2,#6 ;显示:MOV CODES,#11CALL writerightMOV CODES,#0MOV SHUJI21,#0CLR AMOV A,HOUR4MOV B,#10DIV ABMOV A,BMOV SHUJI21,Amov column2,#16mov pagef2,#6MOV CODES,SHUJI21 ;时低位CALL writerightMOV SHUJI22,#0MOV CODES,#0CLR AMOV A,HOUR4MOV B,#10DIV ABMOV SHUJI22,AMOV column2,#8MOV pagef2,#6MOV CODES,SHUJI22 ;时高位CALL writerightMOV column2,#00MOV pagef2,#6MOV CODES,#12 ;时高位CALL writerightBB: RET////////////////////////////////////////////////////DISPLAY: MOV CODES,#0MOV SHUJI1,#0CLR AMOV A,SECONDMOV B,#10DIV ABMOV A,BMOV SHUJI1,AMOV column2,#40MOV pagef2,#2MOV CODES,SHUJI1 ;秒低位CALL writerightMOV SHUJI2,#0MOV CODES,#0CLR AMOV A,SECONDMOV B,#10DIV ABMOV SHUJI2,AMOV column2,#32MOV pagef2,#2MOV CODES,SHUJI2 ;秒高位CALL writerightMOV CODES,#0MOV column2,#24MOV pagef2,#2 ;显示:MOV CODES,#11CALL writerightMOV CODES,#0MOV SHUJI3,#0CLR AMOV A,MINUTEMOV B,#10MOV A,BMOV SHUJI3,AMOV column2,#16MOV pagef2,#2MOV CODES,SHUJI3 ;分低位CALL writerightMOV SHUJI4,#0MOV CODES,#0CLR AMOV A,MINUTEMOV B,#10DIV ABMOV SHUJI4,AMOV column2,#8MOV pagef2,#2MOV CODES,SHUJI4 ;分高位CALL writerightMOV CODES,#0MOV column2,#00MOV pagef2,#2 ;显示:MOV CODES,#11CALL writerightMOV CODES,#0MOV SHUJI5,#0CLR AMOV A,HOURMOV B,#10DIV ABMOV A,BMOV SHUJI5,Amov column,#56mov pagef,#2MOV CODES,SHUJI5 ;时低位lcall writeleftMOV SHUJI6,#0MOV CODES,#0CLR AMOV A,HOURMOV B,#10MOV SHUJI6,AMOV column,#48MOV pagef,#2MOV CODES,SHUJI6 ;时高位CALL writeleftRET////////////////////////////////////////////////writeleft1: ; 左半屏写入16*16数字子程序MOV DPTR,#TABLE2PUSH column1MOV cpage1,#2MOV ccolumn1,#0MOV A,pagef1ANL A,#07hORL A,#0b8hMOV COM,ACALL PRM0MOV A,column1ORL A,#40hMOV COM,ACALL PRM0MOV A,CODESMOV B,#32MUL ABADD A,DPLMOV DPL,AMOV A,BADDC A,DPHMOV DPH,AlOOp3: MOV A,#00hMOVC A,@A+DPTRMOV DAT,ACALL PRM1INC ccolumn1MOV A,ccolumn1INC DPTRCJNE A,#16,lOOp3CLR CYDEC cpage1INC pagef1MOV A,cpage1CJNE A,#0,DD1RET//////////////////////////////////////////////DD1: MOV A,pagef1ANL A,#07hORL A,#0b8hMOV COM,ACALL PRM0POP column1MOV A,column1ANL A,#3fhORL A,#40hMOV COM,ACALL PRM0MOV ccolumn1,#0AJMP lOOp3//////////////////////////////////////////////writeright1: ; 右半屏写入16*16数字子程序MOV DPTR,#TABLE2push column3MOV cpage3,#2MOV ccolumn3,#0MOV A,pagef3ANL A,#07hORL A,#0b8hMOV COM,ACALL PRR0MOV A,column3ORL A,#40hMOV COM,ACALL PRR0MOV A,CODESMOV B,#32MUL ABADD A,DPLMOV DPL,AMOV A,BADDC A,DPHMOV DPH,AlOOp4: MOV A,#00hMOVC A,@A+DPTRMOV DAT,ACALL PRR1INC DPTRINC ccolumn3MOV A,ccolumn3CJNE A,#16,lOOp4CLR CYDEC cpage3INC pagef3MOV A,cpage3CJNE A,#0,DD2RET/////////////////////////////////////////////DD2: MOV A,pagef3ANL A,#07hORL A,#0b8hMOV COM,ACALL PRR0POP column3MOV A,column3ANL A,#3fhORL A,#40hMOV COM,ACALL PRR0MOV ccolumn3,#0AJMP lOOp4///////////////////////////////////////////// writeleft: ; 左半屏写入8*16数字子程序MOV DPTR,#TABLE1PUSH columnMOV cpage,#2MOV ccolumn,#0MOV A,pagefANL A,#07hORL A,#0b8hMOV COM,ACALL PRM0MOV A,columnORL A,#40hMOV COM,ACALL PRM0MOV A,CODESMOV B,#16MUL ABADD A,DPLMOV DPL,AMOV A,BADDC A,DPHMOV DPH,A////////////////////////////////////////////////////LOOP1: MOV A,#00hMOVC A,@A+DPTRMOV DAT,ACALL PRM1INC DPTRINC ccolumnMOV A,ccolumnCJNE A,#8,LOOP1CLR CYDEC cpageINC pagefMOV A,cpageCJNE A,#0,DD3RET/////////////////////////////////////DD3: MOV A,pagefANL A,#07hORL A,#0b8hMOV COM,ACALL PRM0POP columnMOV A,columnANL A,#3fhORL A,#40hMOV COM,ACALL PRM0MOV ccolumn,#0AJMP LOOP1//////////////////////////////////////////////// writeright: ; 右半屏写入8*16数字子程序MOV DPTR,#TABLE1PUSH column2MOV cpage2,#2MOV ccolumn2,#0MOV A,pagef2ANL A,#07hORL A,#0b8hMOV COM,ACALL PRR0MOV A,column2ORL A,#40hMOV COM,ACALL PRR0MOV A,CODESMOV B,#16MUL ABADD A,DPLMOV DPL,AMOV A,BADDC A,DPHMOV DPH,A////////////////////////////////////////////////////LOOP: MOV A,#00hMOVC A,@A+DPTRMOV DAT,ACALL PRR1INC DPTRINC ccolumn2MOV A,ccolumn2CJNE A,#8,LOOPCLR CYDEC cpage2INC pagef2MOV A,cpage2CJNE A,#0,DD4RET/////////////////////////////////////DD4: MOV A,pagef2ANL A,#07hORL A,#0b8hMOV COM,ACALL PRR0POP column2MOV A,column2ANL A,#3fhORL A,#40hMOV COM,ACALL PRR0MOV ccolumn2,#0AJMP LOOP//////////////////////////////////////////////PRM0: CALL DECLR CSA ;写指令代码子程序(左)SETB CSBCLR RSCLR RWMOV OUTPUT,COMSETB ECLR ERET///////////////////////////////////////////////PRM1: CALL DECLR CSA ;写显示数据子程序(左)SETB CSBSETB RSCLR RWMOV OUTPUT,DATSETB ECLR ERET////////////////////////////////////////////////PRR0: CALL DECLR CSB ;写指令代码子程序(右)SETB CSACLR RSCLR RWMOV OUTPUT,COMSETB ECLR ERETPRR1: CALL DECLR CSB ;写显示数据子程序(右)SETB CSASETB RSCLR RWMOV OUTPUT,DATSETB ECLR ERET////////////////////////////////////////////DE: MOV R7,#10DEE2: MOV R6,#25DJNZ R6,$DJNZ R7,DEE2RET////////////////////////////////////////////CLEAR: MOV R4,#00H ;清屏子程序CLEAR1: MOV A,R4ORL A,#0B8HMOV COM,ALCALL PRM0LCALL PRR0MOV COM,#40HLCALL PRM0LCALL PRR0MOV R3,#40HCLEAR2: MOV DA T,#00HLCALL PRM1LCALL PRR1DJNZ R3,CLEAR2INC R4CJNE R4,#08H,CLEAR1RET///////////////////////////////////////////////////INT: MOV COM,#0C0H ;初始化子程序,设置显示起始行为第一行LCALL PRM0LCALL PRR0MOV COM,#3FH ;开显示设置LCALL PRM0LCALL PRR0RET////////////////定时器中断子程序////////////////////////////////INTP0: MOV TH0,#(65536-50000) / 256MOV TL0,#(65536-50000) MOD 256INC COUNTMOV A,COUNTCJNE A,#20,LOPMOV COUNT,#0CALL CHULILOP: RETI/////////////////////////////////////////////////CHULI: INC SECONDMOV A,SECONDCJNE A,#60,LOPMOV SECOND,#0INC MINUTEMOV A,MINUTECJNE A,#60,LOPMOV MINUTE,#0INC HOURMOV A,HOURCJNE A,#24,LOPMOV HOUR,#1RETI//////////////////按键处理模式//////////////////////////////// KEYSCAN: JB BT0,K11JB KEY1,K12SETB BT0LJMP K13K12: CLR BT0CLR BT1LJMP K13K11: JB KEY1,K12JB BT1,K13SETB BT1INC COUNT1MOV A,COUNT1CJNE A,#3,K13MOV COUNT1,#0K13: RET////////////////分加/////////////////////////KEYCHULI1:MOV A,COUNT1CJNE A,#1,K23CLR AIXINGMOV AIXING,MINUTECALL KK1MOV MINUTE,AIXINGRETKEYCHU1: MOV A,COUNT1CJNE A,#1,K23CLR AIXINGMOV AIXING,MINUTE1CALL KK1MOV MINUTE1,AIXINGRETKEYCHU2: MOV A,COUNT1CJNE A,#1,K23CLR AIXINGMOV AIXING,MINUTE2CALL KK1MOV MINUTE2,AIXINGRETKEYCHU3: MOV A,COUNT1CJNE A,#1,K23CLR AIXINGMOV AIXING,MINUTE3CALL KK1MOV MINUTE3,AIXINGRETKEYCHU4: MOV A,COUNT1CJNE A,#1,K23CLR AIXINGMOV AIXING,MINUTE4CALL KK1MOV MINUTE4,AIXINGRETKK1: JB BT2,K21JB KEY2,K22SETB BT2LJMP K23K22: CLR BT2CLR BT3LJMP K23K21: JB KEY2,K22JB BT3,K23SETB BT3INC AIXINGMOV A,AIXINGCJNE A,#60,K23MOV AIXING,#0K23: RET//////////////////时加///////////////////////////////// KEYCHULI11:MOV A,COUNT1CJNE A,#1,K33CLR AIXING1MOV AIXING1,HOURCALL KK2MOV HOUR,AIXING1RETKEYCHU11: MOV A,COUNT1CJNE A,#1,K33CLR AIXING1MOV AIXING1,HOUR1CALL KK2MOV HOUR1,AIXING1RETKEYCHU21: MOV A,COUNT1CJNE A,#1,K33CLR AIXING1MOV AIXING1,HOUR2CALL KK2MOV HOUR2,AIXING1RETKEYCHU31: MOV A,COUNT1CJNE A,#1,K33MOV AIXING1,HOUR3CALL KK2MOV HOUR3,AIXING1RETKEYCHU41: MOV A,COUNT1CJNE A,#1,K33CLR AIXING1MOV AIXING1,HOUR4CALL KK2MOV HOUR4,AIXING1RETKK2: JB BT4,K31JB KEY3,K32SETB BT4LJMP K33K32: CLR BT4CLR BT5LJMP K33K31: JB KEY3,K32JB BT5,K33SETB BT5INC AIXING1MOV A,AIXING1CJNE A,#24,K33MOV AIXING1,#0K33: RET/////////////////分减/////////////////////////////// KEYCHULI2:MOV A,COUNT1CJNE A,#2,K43CLR AIXINGMOV AIXING,MINUTECALL KK3MOV MINUTE,AIXINGRETKEYCHU5: MOV A,COUNT1CJNE A,#2,K43CLR AIXINGMOV AIXING,MINUTE1CALL KK3MOV MINUTE1,AIXINGRETKEYCHU6: MOV A,COUNT1CJNE A,#2,K43CLR AIXINGMOV AIXING,MINUTE2CALL KK3MOV MINUTE2,AIXINGRETKEYCHU7: MOV A,COUNT1CJNE A,#2,K43CLR AIXINGMOV AIXING,MINUTE3CALL KK3MOV MINUTE3,AIXINGRETKEYCHU8: MOV A,COUNT1CJNE A,#2,K43CLR AIXINGMOV AIXING,MINUTE4CALL KK3MOV MINUTE4,AIXINGRETKK3: JB BT2,K41JB KEY2,K42SETB BT2LJMP K43K42: CLR BT2CLR BT3LJMP K43K41: JB KEY2,K42JB BT3,K43SETB BT3DEC AIXINGMOV A,AIXINGCJNE A,#0FFH,K43MOV AIXING,#59K43: RET///////////////时减////////////////////////////////// KEYCHULI21:MOV A,COUNT1CJNE A,#2,K53CLR AIXING1MOV AIXING1,HOURMOV HOUR,AIXING1RETKEYCHU51:MOV A,COUNT1CJNE A,#2,K53CLR AIXING1MOV AIXING1,HOUR1CALL KK4MOV HOUR1,AIXING1RETKEYCHU61:MOV A,COUNT1CJNE A,#2,K53CLR AIXING1MOV AIXING1,HOUR2CALL KK4MOV HOUR2,AIXING1RETKEYCHU71:MOV A,COUNT1CJNE A,#2,K53CLR AIXING1MOV AIXING1,HOUR3CALL KK4MOV HOUR3,AIXING1RETKEYCHU81:MOV A,COUNT1CJNE A,#2,K53CLR AIXING1MOV AIXING1,HOUR4CALL KK4MOV HOUR4,AIXING1RETKK4: JB BT4,K51JB KEY3,K52SETB BT4LJMP K53K52: CLR BT4CLR BT5LJMP K53K51: JB KEY3,K52JB BT5,K53DEC AIXING1MOV A,AIXING1CJNE A,#0FFH,K53MOV AIXING1,#23K53: RET////////////////切换模式////////////////////////////////////// KEYSCAN1: JB BT8,K61JB KEY4,K62SETB BT8LJMP K63K62: CLR BT8CLR BT9LJMP K63K61: JB KEY4,K62JB BT9,K63SETB BT9CPL BT7K63: RET///////////////选择模式////////////////////////////////// CHULI1: JB BT10,K71JB KEY5,K72SETB BT10LJMP K73K72: CLR BT10CLR BT11LJMP K73K71: JB KEY5,K72JB BT11,K73SETB BT11INC COUNT4MOV A,COUNT4CJNE A,#5,K73MOV COUNT4,#0K73: RET///////////////选择模式调制////////////////////////////////// CHULI2: JB BT12,K81JB KEY6,K82SETB BT12LJMP K83K82: CLR BT12CLR BT13LJMP K83K81: JB KEY6,K82JB BT13,K83SETB BT13INC COUNT5MOV A,COUNT5CJNE A,#2,K83MOV COUNT5,#0K83: RET;*************************************字模表table1: ;数字字模表DB 0F0h,0F8h, 0Ch,04h,04h,0Ch,0F8h,0F0h,0Fh,1Fh,30h,20h,20h,30h,1Fh,0Fh ;0 /* (8 X 16 , 宋体)*/DB 00h,00h,08h,0F8h,0FCh,00h,00h,00h,00h,00h,20h,3Fh,3Fh,20h,00h,00h ;1 /* (8 X 16 , 宋体)*/DB 30h,38h,0Ch,04h,04h,0Ch,0F8h,0F0h,20h,30h,38h,2Ch,26h,23h,21h,38h ;2 /* (8 X 16 , 宋体)*/DB 10h,18h,0Ch,84h,84h,0CCh,78h,30h,08h,18h,30h,20h,20h,31h,1Fh,0Eh ;3/* (8 X 16 , 宋体)*/DB 00h,0C0h,70h,18h,0FCh,0FEh,00h,00h,07h,05h,04h,24h,3Fh,3Fh,24h,04h ;4 /* (8 X 16 , 宋体)*/DB 0FCh,0FCh,0C4h,44h,44h,0C4h,84h,04h,08h,18h,30h,20h,20h,30h,1Fh,0Fh ;5 /* (8 X 16 , 宋体)*/DB 0F0h,0F8h,8Ch, 44h,44h,0CCh,98h,10h,0Fh,1Fh,30h,20h,20h,30h,1Fh,0Fh ;6 /* (8 X 16 , 宋体)*/DB 1Ch,0Ch,0Ch,0Ch,0CCh,0ECh,3Ch,1Ch,00h,00h,3Ch,3Fh,03h,00h,00h,00h ;7 /* (8 X 16 , 宋体)*/DB 30h,78h,0CCh,84h,84h,0CCh,78h,30h,0Eh,1Fh,31h,20h,20h,31h,1Fh,0Eh ;8 /* (8 X 16 , 宋体)*/DB 0F0h,0F8h,0Ch,04h,04h,0Ch,0F8h,0F0h,08h,19h,33h,22h,22h,33h,1Fh,0Fh ;9 /* (8 X 16 , 宋体)*/DB 0F0h,0F8h,0Ch,04h,04h,0Ch,0F8h,0F0h,0Fh,1Fh,30h,20h,20h,30h,1Fh,0Fh ;10 /* (8 X 16 , 宋体)*/DB 00H ,00H ,00H ,0C0H ,0C0H ,00H, 00H ,00H ,00H ,00H, 00H ,30H ,30H ,00H ,00H ,00H;":",11/* (8 X 16 , 宋体)*/DB 00H, 00H ,00H, 00H, 00H ,00H ,00H ,00H, 00H ,01H, 01H ,01H, 01H ,01H, 01H ,01H;"-",12 /* (8 X 16 , 宋体)*/DB 00H ,80H, 80H ,0E0H ,80H ,80H, 00H, 00H ,00H, 00H ,00H ,1FH, 20H, 20H, 00H ,00H;"t",13/* (8 X 16 , 宋体)*/DB 00H ,80H, 80H ,98H ,00H ,00H ,00H, 00H, 00H ,20H ,20H ,3FH, 20H, 20H ,00H ,00H;"i",14 /* (8 X 16 , 宋体)*/DB 80H, 80H ,80H ,80H ,80H ,00H ,00H ,00H ,20H, 3FH ,00H ,3FH ,00H ,3FH ,20H, 00H;"m",15/* (8 X 16 , 宋体)*/DB 00H ,00H ,80H ,80H, 80H ,00H ,00H ,00H ,00H ,1FH ,22H ,22H ,22H ,13H, 00H ,00H;"e",16 /* (8 X 16 , 宋体)*/table2: ;汉字DB 00H,00H,00H,0BEH,2AH,2AH,2AH,0EAH,2AH,2AH,2AH,2AH,3EH,00H,00H,00H;DB 00H,48H,46H,41H,49H,49H,49H,7FH,49H,49H,49H,49H,49H,41H,40H,00H;"星",0/* (16 X 16 , System )*/DB 40H,44H,24H,14H,0FFH,94H,64H,40H,24H,14H,0FFH,0CH,34H,64H,24H,00H;DB 00H,80H,88H,88H,46H,45H,29H,31H,11H,09H,05H,03H,01H,00H,00H,00H;"梦",1/* (16 X 16 , System )*/DB 40H,44H,24H,94H,44H,3CH,05H,46H,84H,7CH,04H,14H,64H,24H,04H,00H;DB 00H,84H,85H,44H,24H,14H,0CH,07H,0CH,14H,24H,64H,0C4H,44H,04H,00H;"奕",2/* (16 X 16 , System )*/DB 20H,38H,0A7H,62H,10H,20H,0A0H,6CH,6BH,0AAH,2AH,3AH,26H,0A0H,20H,00H;DB 12H,13H,12H,0AH,29H,25H,12H,12H,49H,85H,7FH,02H,0DH,18H,08H,00H;"缘",3/* (16 X 16 , System )*/DB 00H,00H,00H,00H,0FFH,00H,00H,00H,80H,7FH,80H,00H,00H,00H,00H,00H;DB 40H,20H,18H,07H,80H,41H,36H,18H,07H,00H,01H,06H,18H,70H,20H,00H;"从",4/* (16 X 16 , System )*/DB 08H,08H,0C8H,0FFH,48H,88H,08H,00H,0FEH,02H,02H,02H,0FEH,00H,00H,00H;DB 04H,03H,00H,0FFH,00H,41H,30H,0CH,03H,00H,00H,00H,3FH,40H,78H,00H;"机",5/* (16 X 16 , System )*/DB 00H,80H,80H,80H,80H,80H,80H,80H,80H,80H,80H,80H,80H,0C0H,80H,00H;DB 00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H;"一",6/* (16 X 16 , System )*/DB 00H,00H,04H,04H,04H,04H,04H,04H,04H,04H,04H,06H,04H,00H,00H,00H;DB 00H,10H,10H,10H,10H,10H,10H,10H,10H,10H,10H,10H,10H,18H,10H,00H;"二",7/* (16 X 16 , System )*/DB 00h,00h,00h,00h,00h,00h,00h,30h,30h,00h,00h,00h,00h,00h,00h,00h ; ":",8DB 00h,00h,00h,00h,00h,00h,00h,0Ch,0Ch,00h,00h,00h,00h,00h,00h,00h;/* (16 X 16 , 宋体)*/DB00H,82H,82H,82H,0BAH,0AAH,0AAH,0ABH,0AAH,0AAH,0BAH,82H,82H,0C2H,80H,00H; DB 02H,41H,40H,20H,10H,0EH,02H,02H,02H,3EH,40H,40H,42H,41H,70H,00H;"亮",9/* (16 X 16 , 宋体)*/DB 00H,02H,02H,0E2H,02H,02H,82H,7EH,0C2H,02H,82H,42H,33H,02H,00H,00H;DB 00H,40H,21H,10H,08H,06H,01H,00H,00H,03H,0CH,18H,30H,60H,20H,00H;"灭",10/* (16 X 16 , 宋体)*/DB 08H ,0F8H, 08H ,00H, 00H ,00H ,00H ,00H, 00H, 00H ,00H, 00H, 00H ,00H, 00H, 00H;DB 20H ,3FH ,20H ,20H ,20H ,20H, 30H, 00H ,00H ,00H ,00H ,00H ,00H, 00H ,00H, 00H;"L",11/* (16 X 16 , 宋体)*/DB 00H,00H,00H,00H,00H,00H,00H,00H,0FH,00H,10H,80h,16H,80H,16H,80H;DB 10H,80H,0FH,00H,00H,00H,00H,00H,00H,00H,00H,00h,00H,00H,00H,00H;"亮",12"E",12 /* (16 X 16 , 宋体)*/DB 08H ,0F8H ,08H ,08H ,08H ,10H ,0E0H ,00H ,00H ,00H ,00H ,00H ,00H ,00H, 00H,00H; DB20H ,3FH ,20H ,20H ,20H ,10H ,0FH ,00H ,00H ,00H ,00H ,00H ,00H ,00H ,00H ,00H;"D",13/* (16 X 16 , 宋体)*/////////"14-23"////////////////模式选择///////////////////////////////////////DB 02H,02H, 32H ,52H ,92H ,1FH ,32H ,52H ,12H ,1FH ,92H ,52H ,32H ,02H ,02H ,00H;DB 00H,42H, 42H, 22H ,12H ,0AH ,06H ,0FFH ,06H ,0AH ,12H ,32H ,62H ,22H ,02H ,00H;"菜",14/* (16 X 16 , 宋体)*/DB 00H ,00H ,0F8H ,28H ,29H ,2EH ,2AH ,0F8H ,28H ,2CH ,2BH ,2AH ,0F8H ,00H ,00H ,00H; DB 08H ,08H ,0BH ,09H ,09H ,09H ,09H ,0FFH ,09H ,09H ,09H ,09H ,0BH ,08H ,08H ,00H;"单",15/* (16 X 16 , 宋体)*/DB 00H ,0FCH ,44H ,44H ,44H ,0FCH ,10H ,90H ,10H ,10H ,10H ,0FFH ,10H ,10H ,10H ,00H; DB 00H ,07H ,04H ,04H ,04H ,07H ,00H ,00H ,03H ,40H ,80H ,7FH ,00H ,00H ,00H, 00H;"时",16/* (16 X 16 , 宋体)*/DB 40H ,30H, 2CH ,0EBH ,28H ,28H ,00H ,0F8H ,08H ,08H ,0FFH ,08H ,08H ,0F8H ,00H ,00H;DB 01H ,01H ,01H ,0FFH ,41H ,21H ,00H, 01H ,01H ,01H ,0FFH ,01H ,01H ,01H ,00H, 00H;"钟",17/* (16 X 16 , 宋体)*/DB 40H ,42H, 42H ,42H ,42H ,0FEH ,42H ,42H ,42H ,42H ,0FEH ,42H ,42H ,42H, 42H ,00H; DB 00H ,40H ,20H ,10H ,0CH ,03H ,00H ,00H ,00H ,00H ,7FH ,00H ,00H ,00H ,00H ,00H;"开",18/* (16 X 16 , 宋体)*/DB 00H,10H ,10H ,10H ,11H ,1EH ,14H ,0F0H ,10H ,18H ,17H ,12H ,18H, 10H ,00H, 00H;DB 01H,81H ,41H ,21H ,11H ,09H ,05H ,03H ,05H ,09H ,31H ,61H ,0C1H, 41H ,01H ,00H;"关",19/* (16 X 16 , 宋体)*/DB 20H ,21H ,0EEH ,04H ,00H ,00H ,0FFH ,29H ,0A9H, 0BFH ,0A9H ,0A9H ,01H ,0FFH ,00H ,00H;DB 00H ,00H ,1FH ,88H ,44H ,30H ,0FH ,00H ,0FH ,04H ,04H ,4FH ,80H ,7FH ,00H ,00H;"调",20/* (16 X 16 , 宋体)*/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;"光",21/* (16 X 16 , 宋体)*/DB 40H ,41H ,0CEH, 04H ,00H ,80H ,40H ,0BEH ,82H ,82H ,82H ,0BEH ,0C0H,40H ,40H ,00H;DB 00H ,00H ,7FH ,20H ,90H ,80H ,40H ,43H ,2CH ,10H ,10H ,2CH ,43H ,0C0H ,40H, 00H;"设",22/* (16 X 16 , 宋体)*/DB 00H ,10H ,0CH ,0A4H ,24H ,24H ,25H ,0E6H ,24H ,24H, 24H ,24H ,14H, 0CH,04H,00H; DB 40H ,20H ,18H ,07H ,08H ,10H ,20H ,7FH ,42H ,42H, 42H ,42H ,40H,40H ,00H,00H;"定",23/* (16 X 16 , 宋体)*/。

12864显示程序

12864显示程序

2009-12-10 19:19/**------------------------------------------------------------------- *本程序在keil下编译。

如读者有更好的建议或对程序有修改意见,*请与我联系:QQ:910972385*------------------------------------------------------------------- *题目:12864显示*------------------------------------------------------------------- *说明:中文字库是为了proteus仿真使用,要是已经有字库的12864实际硬件请做适当修改中文字库取模方式为:纵向,字节倒序*------------------------------------------------------------------- *注:本程序修改自中文章*------------------------------------------------------------------- */#include <reg51.h>#include <intrins.h>#define unint unsigned int#define unchar unsigned char#define Databus P0 /*液晶数据总线*/sbit RS=P2^2; /*数据\指令选择*/sbit RW=P2^1; /*读\写选择*/sbit EN=P2^0; /*读\写使能*/sbit cs1=P2^3; /*片选1*/sbit cs2=P2^4; /*片选2*//********************************//* 定义中文字库 *//********************************/unchar code Hzk[]={/*-- 文字: 浙 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x61,0x86,0x60,0x08,0x08,0xFF,0x88,0x08,0xFE,0x22,0x22,0xE2,0x22 ,0x22,0x00,0x04,0xFC,0x03,0x00,0x42,0x81,0x7F,0x40,0x30,0x0F,0x00,0x00,0xFF,0x00 ,0x00,0x00,/*-- 文字: 江 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x60,0x01,0xC6,0x30,0x00,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04 ,0x00,0x00,0x04,0x04,0x7E,0x01,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x00,/*-- 文字: 师 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0xFC,0x00,0x00,0xFF,0x00,0xF2,0x12,0x12,0x12,0xFE,0x12,0x12,0x12 ,0xF2,0x00,0x40,0x27,0x10,0x0E,0x01,0x00,0x0F,0x00,0x00,0x00,0xFF,0x00,0x04,0x08 ,0x07,0x00,/*-- 文字: 范 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x44,0x94,0xA4,0x64,0x04,0x0F,0x04,0xE4,0x24,0x2C,0x2F,0x24,0xE4,0x04 ,0x04,0x00,0x08,0x09,0xF8,0x04,0x03,0x00,0x00,0x3F,0x40,0x40,0x42,0x46,0x43,0x70 ,0x00,0x00,/*-- 文字: 大 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x20,0x20,0x20,0x20,0x20,0x20,0xA0,0x7F,0xA0,0x20,0x20,0x20,0x20,0x20 ,0x20,0x00,0x00,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x01,0x06,0x08,0x30,0x60,0xC0 ,0x40,0x00,/*-- 文字: 学 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x40,0x30,0x10,0x12,0x5C,0x54,0x50,0x51,0x5E,0xD4,0x50,0x18,0x57,0x32 ,0x10,0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x02,0x02,0x02,0x02,0x02 ,0x02,0x00,/*-- 文字: 职 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x02,0x02,0xFE,0x92,0x92,0xFE,0x02,0x00,0xFE,0x82,0x82,0x82,0x82,0xFE ,0x00,0x00,0x10,0x10,0x0F,0x08,0x08,0xFF,0x04,0x44,0x21,0x1C,0x08,0x00,0x04,0x09 ,0x30,0x00,/*-- 文字: 业 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x10,0x60,0x80,0x00,0xFF,0x00,0x00,0x00,0xFF,0x00,0x80,0x60,0x38 ,0x10,0x00,0x20,0x20,0x20,0x23,0x21,0x3F,0x20,0x20,0x20,0x3F,0x22,0x21,0x20,0x30 ,0x20,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,/*-- 文字: 学 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x40,0x30,0x10,0x12,0x5C,0x54,0x50,0x51,0x5E,0xD4,0x50,0x18,0x57,0x32 ,0x10,0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x02,0x02,0x02,0x02,0x02 ,0x02,0x00,/*-- 文字: 院 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0xFE,0x02,0x32,0x4A,0x86,0x0C,0x24,0x24,0x25,0x26,0x24,0x24,0x24,0x0C ,0x04,0x00,0xFF,0x00,0x02,0x04,0x83,0x41,0x31,0x0F,0x01,0x01,0x7F,0x81,0x81,0x81 ,0xF1,0x00,/*-- 文字: 应 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0xFC,0x44,0x84,0x04,0x14,0x25,0xC6,0x84,0x04,0x04,0xE4,0x44 ,0x00,0x00,0x40,0x38,0x07,0x20,0x20,0x2F,0x24,0x20,0x23,0x30,0x2C,0x23,0x20,0x20 ,0x20,0x00,/*-- 文字: 用 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x00,0xFE,0x22,0x22,0x22,0x22,0xFE,0x22,0x22,0x22,0x22,0xFE ,0x00,0x00,0x80,0x40,0x30,0x0F,0x02,0x02,0x02,0x02,0xFF,0x02,0x02,0x42,0x82,0x7F ,0x00,0x00,/*-- 文字: 电 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0xF8,0x48,0x48,0x48,0x48,0xFF,0x48,0x48,0x48,0x48,0xF8,0x00 ,0x00,0x00,0x00,0x00,0x0F,0x04,0x04,0x04,0x04,0x3F,0x44,0x44,0x44,0x44,0x4F,0x40 ,0x70,0x00,/*-- 文字: 子 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x02,0x02,0x02,0x02,0x02,0xE2,0x12,0x0A,0x06,0x02,0x00,0x80 ,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x41,0x81,0x7F,0x01,0x01,0x01,0x01,0x01,0x01 ,0x01,0x00,/*-- 文字: 技 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/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,/*-- 文字: 教 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x14,0x94,0xD4,0xBF,0x94,0x9C,0x14,0x50,0xF8,0x0F,0x08,0x88,0x78 ,0x08,0x00,0x09,0x09,0x48,0x88,0x7E,0x05,0x44,0x44,0x20,0x20,0x13,0x0C,0x33,0xC0 ,0x40,0x00,/*-- 文字: 育 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x04,0x04,0x24,0xE4,0xB4,0xAC,0xA5,0xA6,0xA4,0xA4,0xAC,0xF4,0x24,0x04 ,0x04,0x00,0x00,0x00,0x00,0xFF,0x0A,0x0A,0x0A,0x0A,0x0A,0x4A,0x8A,0x7F,0x00,0x00 ,0x00,0x00,/*-- 文字: 杨 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x08,0x08,0xC8,0xFF,0x48,0x88,0x0A,0x42,0x62,0xD2,0x4A,0xC6,0x42,0xC0 ,0x00,0x00,0x04,0x03,0x00,0xFF,0x00,0x01,0x08,0x24,0x13,0x08,0x06,0x41,0x80,0x7F ,0x00,0x00,/*-- 文字: 子 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x02,0x02,0x02,0x02,0x02,0xE2,0x12,0x0A,0x06,0x02,0x00,0x80 ,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x41,0x81,0x7F,0x01,0x01,0x01,0x01,0x01,0x01 ,0x01,0x00,/*-- 文字: 诺 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x21,0x26,0xE2,0x00,0x00,0x44,0x44,0x5F,0xC4,0x64,0x44,0x44,0x5F,0x44 ,0x44,0x00,0x00,0x00,0x3F,0x10,0x08,0x10,0x08,0x7E,0x23,0x22,0x22,0x22,0x22,0x7E ,0x00,0x00,/****************************以下编码用来填充空白屏幕****************************//*-- 文字: --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,/*-- 文字: --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,};/****************************************//* 定义ASCII字库8列*16行 *//****************************************/unchar code Ezk[]={/*-- 文字: Q --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50 ,0x4F,0x00,/*-- 文字: Q --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50/*-- 文字: 9 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11 ,0x0F,0x00,/*-- 文字: 1 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20 ,0x00,0x00,/*-- 文字: 0 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10 ,0x0F,0x00,/*-- 文字: 9 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11 ,0x0F,0x00,/*-- 文字: 7 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00 ,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,/*-- 文字: 8 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22 ,0x1C,0x00,/*-- 文字: 5 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11/****************************一下编码用来填充空白屏幕***************************//*-- 文字: --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,/*-- 文字: --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,/*-- 文字: --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,/*-- 文字: --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,/*-- 文字: --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,/*-- 文字: --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,/*-- 文字: --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,};/*状态检查,LCD是否忙*/void CheckState(){unchar dat; /*状态信息,判断是否忙*/RS=0; /*数据\指令选择,D/I(RS)=“L” ,表示DB7∽DB0 为显示指令数据*/RW=1; /*R/W=“H” ,E=“H”数据被读到DB7∽DB0*/do{Databus=0x00;EN=1; /*EN下降源*/_nop_(); /*一个时钟延时*/dat=Databus;EN=0;dat=0x80 & dat;/*仅当第7位为0时才可操作(判别busy信号)*/}while(!(dat==0x00));}/*写命令到LCD中*/SendCommandToLCD(unchar com){CheckState();/*状态检查,LCD是否忙*/RS=0; /*向LCD发送命令。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
{
LCD_PSB = 1; //并口方式
write_cmd(0x34); //扩充指令操作
delay_1ms(1);
write_cmd(0x30); //基本指令操作
delay_1ms(1);
write_cmd(0x0C); //显示开,关光标
delay_1ms(1);
write_cmd(0x01); //清除LCD的显示内容
delay_1ms(1);
}
/*********************************************************/
/* */
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
uint a,b,bai,shi,ge,num;
/*TS12864A-3 端口定义*/
#define LCD_data P0 //数据口
sbit wr=P2^0;
sbit rd=P2^1;
sbit CS=P2^2;
uchar code dis1[] = {"光电测速计"};
uchar code dis2[] = {"倒计时: 秒"};
uchar code dis3[] = {"speed: r/s"};
uchar code dis4[] = {"指导教师:童艳荣"};
/* */
/*******************************************************************/
void lcd_init()
void main() 源自 uchar adval;
CS=0;
delay_1ms(1); //延时
lcd_init(); //初始化LCD
lcd_pos(0,0); //设置显示位置为第一行的第1个字符
/* */
/*检查LCD忙状态 */
/*lcd_busy为1时,忙,等待。lcd-busy为0时,闲,可写指令与数据。 */
/* */
/*******************************************************************/
void write_dat(uchar dat)
/*******************************************************************/
void write_cmd(uchar cmd)
{
while(lcd_busy());
LCD_RS = 0;
while(1)
{
wr=1;
delay_1ms(1);
wr=0;
delay_1ms(1);
wr=1;
delay_1ms(100);
P1=0xff;
rd=1;
delay_1ms(1);
LCD_RW = 0;
LCD_EN = 0;
_nop_();
_nop_();
P0 = cmd;
delay_1ms(1);
LCD_EN = 1;
delay_1ms(1);
LCD_EN = 0;
}
/*******************************************************************/
LCD_EN = 0;
}
/* 设定显示位置 */
void lcd_pos(uchar X,uchar Y)
{
uchar pos;
if (X==0)
{
while(lcd_busy());
LCD_RS = 1;
LCD_RW = 0;
LCD_EN = 0;
P0 = dat;
delay_1ms(1);
LCD_EN = 1;
delay_1ms(1);
{X=0x81;}
else if (X==1)
{X=0x90;}
else if (X==2)
{X=0x88;}
else if (X==3)
{X=0x98;}
pos = X+Y ;
write_cmd(pos); //显示地址
rd=0;
delay_1ms(1);
num=P1;
bai=num/100;
shi=num%100/10;
ge=num%10;
lcd_pos(2,2); //设置显示位置为第四行的第1个字符
return(result);
}
/*******************************************************************/
/* */
write_dat(0x30+bai);
write_dat(0x30+shi);
write_dat(0x30+ge); //显示字符
}
}
/* 主程序 */
/* */
/*********************************************************/
/* */
/*******************************************************************/
bit lcd_busy()
/*写指令数据到LCD */
/*RS=L,RW=L,E=高脉冲,D0-D7=指令码。 */
/* */
void delay_1ms(uint x)
{
uint i,j;
for(j=0;j<x;j++)
{
for(i=0;i<110;i++); }
}
/*******************************************************************/
/* */
/*写显示数据到LCD */
/*RS=H,RW=L,E=高脉冲,D0-D7=数据。 */
{
bit result;
LCD_RS = 0;
LCD_RW = 1;
LCD_EN = 1;
delay_1ms(1);
result = (bit)(P0&0x80);
LCD_EN = 0;
sbit LCD_RS = P2^4; //寄存器选择输入
sbit LCD_RW = P2^5; //液晶读/写控制
sbit LCD_EN = P2^6; //液晶使能控制
sbit LCD_PSB = P2^7; //串/并方式控制
}
/*******************************************************************/
/* */
/* LCD初始化设定 */
相关文档
最新文档