您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 酒店餐饮 > HDG12864L-3电路图及程序
程序:#includereg51.h#includeintrins.h#defineLCDP1sbitA=P3^2;sbitRW=P3^1;sbitE=P3^0;unsignedcharcodebao[]={0x80,0x40,0x20,0xD8,0x4F,0x4A,0x48,0x48,0x48,0xC8,0x08,0x08,0xFC,0x08,0x00,0x00,0x00,0x00,0x00,0x3F,0x42,0x42,0x42,0x42,0x42,0x43,0x48,0x50,0x4F,0x40,0x70,0x00,};unsignedcharcodegang[]={0x40,0x30,0xEF,0x24,0x24,0x24,0x04,0xFE,0x12,0x22,0xC2,0x22,0x1A,0x02,0xFE,0x00,0x01,0x01,0x7F,0x21,0x11,0x01,0x00,0xFF,0x04,0x03,0x00,0x01,0x46,0x80,0x7F,0x00,};unsignedcharcodeji[]={0x00,0x10,0x08,0xFC,0x57,0x54,0x54,0x54,0xFD,0x56,0x54,0x54,0x54,0x00,0x00,0x00,0x00,0x44,0x44,0x25,0x25,0x15,0x0D,0xFF,0x05,0x0D,0x15,0x25,0x65,0x25,0x04,0x00,};unsignedcharcodetuan[]={0x00,0xFE,0x02,0x12,0x12,0x12,0x92,0x72,0xFE,0x12,0x12,0x12,0x02,0xFE,0x00,0x00,0x00,0xFF,0x48,0x44,0x42,0x41,0x50,0x60,0x5F,0x40,0x40,0x40,0x40,0xFF,0x00,0x00,};unsignedcharcodewan[]={0x00,0x02,0x02,0x02,0x02,0x82,0x7E,0x22,0x22,0x22,0x22,0xF2,0x22,0x02,0x02,0x00,0x00,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x20,0x60,0x20,0x1F,0x00,0x00,0x00,0x00,};unsignedcharcodeteng[]={0x00,0xFE,0x12,0x12,0xFE,0x29,0xAE,0xEA,0xB8,0xAF,0xA8,0x6C,0xAB,0xAA,0x20,0x00,0xC0,0x3F,0x41,0x81,0x7F,0x01,0x10,0x17,0x14,0x14,0x57,0x84,0x7C,0x03,0x01,0x00,};unsignedcharcodegong[]={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,};unsignedcharcodesi[]={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,};unsignedcharcodewu[]={0x00,0x00,0x80,0xBE,0xA2,0xA2,0xA2,0xA2,0xA2,0xA2,0xA2,0xBE,0x80,0x00,0x00,0x00,0x84,0x84,0x44,0x44,0x24,0x14,0x0C,0x07,0x0C,0x14,0x24,0x64,0xC4,0x44,0x04,0x00,};unsignedcharcodedi[]={0x40,0x41,0xCE,0x04,0x00,0xF0,0x90,0x90,0x90,0xFF,0x90,0x90,0x90,0xF0,0x00,0x00,0x40,0x20,0x1F,0x20,0x40,0x5F,0x48,0x48,0x48,0x4F,0x48,0x48,0x48,0x5F,0x40,0x00,};voidmdelay(intdelay){inti;for(;delay0;delay--){for(i=0;i80;i++)//1ms延时{;}}}voidbusytest(){A=0;RW=1;P1=0x00;E=1;while(P1&0x08);E=0;}voidwritevalue(value){busytest();A=0;RW=0;LCD=value;_nop_();_nop_();E=1;_nop_();_nop_();E=0;}voidwritedata(data1){busytest();A=1;RW=0;_nop_();_nop_();LCD=data1;E=1;_nop_();_nop_();E=0;mdelay(20);}voiddisplay(inta,intb,char*c){intn;for(n=0;n=15;n++){writevalue(a);//列(页)设置_nop_();_nop_();_nop_();writevalue(b);//行设置高四位_nop_();_nop_();_nop_();writevalue(0x00+n);//行设置低四位_nop_();_nop_();_nop_();writedata(c[n]);mdelay(20);writevalue(a+1);//列(页)设置_nop_();_nop_();_nop_();writevalue(b);//行设置高四位_nop_();_nop_();_nop_();writevalue(0x00+n);//行设置低四位_nop_();_nop_();_nop_();writedata(c[n+16]);mdelay(20);}}main(){writevalue(0xaf);//显示开writevalue(0xa1);//正显示while(1){display(0xB1,0x10,bao);display(0xB1,0x11,gang);display(0xB1,0x12,ji);display(0xB1,0x13,tuan);display(0xB1,0x14,wan);display(0xB1,0x15,teng);display(0xB1,0x16,gong);display(0xB1,0x17,si);display(0xB5,0x13,wu);display(0xB5,0x14,di);}}HDG12864L-3语句说明:(1):显示器开关10101110(1)0为关1为开,使用前必须用次命令开启12864(2):设置开始行01*******为开始行地址,共64行可设置,是竖直方向的,无特殊情况可以不用。(3):设置页地址1011*****为页地址,共8页,竖直方向,每页高度即为1个字节。(4):设置横向位地址高四位0001*****为横向128位的第几位的十进制数的高四位。(5):设置横向位地址低四位0000*****为横向128位的第几位的十进制数的低四位。(6):查看是否忙****0000若最高位为1,则为忙(7):向12864写数据********命令与数据用引脚1和0区分,读与写也用引脚区分,具体看PDF(8):向12864读数据********只能读数据,不能读命令,引脚状态见PDF。(9):横向位置顺序设置10100000(1)设置SEG(PDF里有图示)方向,0为从右到左显示,1为从左到右显示。(10)::12864点阵正反显示设置10100110(1)0为正常显示(即1点亮0灭),1为反向显示(0为亮1为灭)。(11):12864全部点阵正反显示设置10100100(1)0为正常显示(即1点亮0灭),1为反向显示(0为亮1为灭),与上面命令的区别是,上面是对输入命令后再写入得数据起作用,而该命令是对全屏幕的数据起作用。(12);设置电压偏差10100010(1)设置液晶驱动电压偏差率,具体见PDF,一般默认即可,不需要设置。(13):开启横向位地址加111100000横向位地址增量,写数据时自动加1,读数据时不加。(默认开启)(14):结束横向位地址加111101110结束后再开启必须输入上条命令(15):复位11100010内部复位(16):竖直行顺序正反设置11000(1)***设置C0M正反,0为从下到上显示,1为从上到下显示,即地址增量是从上到下。(17):功率控制设置001010****为操作模式。设置内部电压供应操作模式,具体模式见PDF。(一般不用设置,默认即可)(18):V5的电势差稳压器的内部电阻率设定00100****为选择内部电阻率模式。(19):静态指标设置10101100(1)0为关1为开。(20):静态指标寄存器设置********最低位*代表FLASH模式设置,命令结合上条使用,只有在上调开启时才可设置。(21):测试1111****命令IC测试,不要随便用这条命令。(22):测试模式复位11110000在输入页面刷新。
本文标题:HDG12864L-3电路图及程序
链接地址:https://www.777doc.com/doc-2108784 .html