HT1625液晶屏驱动程序.docVIP

  • 226
  • 0
  • 约3.01千字
  • 约 5页
  • 2018-07-04 发布于河南
  • 举报
HT1625液晶屏驱动程序

HT1625液晶屏驱动程序 #include reg51.h? ? #define uchar unsigned char #define SYSDIS??? 0x00 #define SYSEN???? 0x01 #define LCDOFF??? 0x02 #define LCDON???? 0x03 #define TIMERDIS? 0x04 #define WDTDIS??? 0x05 #define TIMEREN?? 0x06 sbit LCS=P3^4;????????????? //片选 sbit LRD=P1^5;??????????? //读(上升沿) sbit LWR=P1^6;????????? //写(上升沿) sbit LDA=P1^7;???????? //数据 sbit LIGHT=P3^6;????? //背光 sbit LIRQ=P3^2;????? //看门狗(计数器)溢出标志回馈给中断 ? //空延时 void nop() { uchar i?; ?for(i=0;i5;i++); } ? ?/************************************** * 给1625发送命令和地址 ***************************************/ void SendBit_1625(uchar mdata, uchar cnt) //mdata 的高cnt 位写入HT1625,高位在前 { uchar i; for(i =0; i cnt; i ++) { if((mdata0x80)==0) LDA=0; else ??? LDA=1; LWR=0; nop(); LWR=1; mdata=1; } } /************************************** * 给1625发送数据 ***************************************/ void SendDataBit_1625(uchar mdata,uchar cnt) //mdata 的低cnt 位写入HT1625,低位在前 { uchar i; for(i =0; i cnt; i ++) { if((mdata0x01)==0) LDA=0; else LDA=1; LWR=0; nop(); LWR=1; mdata=1; } } /************************************** *读一个地址 ************************************** uchar Read_1625(uchar addr,uchar cnt) { uchar i,rd=0x00; LCS=0; SendBit_1625(0xc0,3); //读入标志码110 SendBit_1625(addr1,7); //写入7 位addr //读入的数据放在rd的低4 位 for(i=0; icnt; i++) { if(LDA) rd|=0x08; else rd=0xf7; LRD=0; nop(); LRD=1; rd=1; } if(LDA) rd|=0x08; else rd=0xf7; LCS=1; return rd; } ???? */ /************************************** * 给1625发送命令控制字--参考define定义 ***************************************/ void SendCmd(uchar command) { LCS=0; SendBit_1625(0x80,3); //写入标志码100 SendBit_1625(command,9); //写入9 位数据,其中前8 位为command 命令,最后1 位任意 LCS=1; } /************************************** * 写一个地址 ***************************************/ void Write_1625(uchar addr,uchar mdata) { LCS=0; SendBit_1625(0xa0,3); //写入标志码101 SendBit_1625(addr1,7); //写入7 位addr SendDataBit_1625(mdata,4); //写入mdata 的低4 位 LCS=1; } ? /************************************** * 从一个地址开始连续写 **************************

文档评论(0)

1亿VIP精品文档

相关文档