单片机采用串行方式对LCD12864的驱动.doc
《单片机采用串行方式对LCD12864的驱动.doc》由会员分享,可在线阅读,更多相关《单片机采用串行方式对LCD12864的驱动.doc(14页珍藏版)》请在三一办公上搜索。
1、单片机采用串行方式对LCD12864的驱动fileDescription: LCD12864 驱动 ,采用串行方式,Author:kassey126July,22th,2005*/i ncludei ncludesbit SCLK =P1 /Esbit SID =P1; /RWsbit RST =P1; / low acTIve 可以不用,也就是说,只用两条线和LCD通信#define ROW1 0x80#define ROW2 0x90#define ROW3 0x88#define ROW4 0x98unsigned char code AC_TABLE=0x80,0x81,0x82,0x
2、83,0x84,0x85,0x86,0x87, /第一行汉字位置0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97, /第二行汉字位置0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f, /第三行汉字位置0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f, /第四行汉字位置;/*FucnTIon: delay10US(char x)DescripTIon: delay for 10 usParameter: xAuthor:kassey126Date: July,7th,2005*/void delay10US
3、(uchar x)uchar k;for(k=0;k/*FucnTIon: delay1MS(char x)Description: delay for 10 usParameter: x delay for 1MSAuthor:kassey126Date: July,7th,2005*/void delay1MS(uchar x)uchar k,j;x=x1;for(k=0;k for(j=0;j255;j+)_nop_();void SendByteLCD(uchar WLCDData)uchar i;for(i=0;i8;i+)if(WLCDDataelse SID=0;SCLK=0;S
4、CLK=1SPIWR(uchar Wdata,uchar RS)SendByteLCD(0xf8+(RS1);SendByteLCD(WdataSendByteLCD(Wdata4)void SendCMD(uchar CMD)SPIWR(CMD,0);delay10US(90);/8155来模拟串行通信,所以,加上8155的延时,void SendData(uchar Data)SPIWR(Data,1);void LCDInit()RST=0;delay1MS(50);RST=1;SendCMD(0x30);/功能设置,一次送8位数据,基本指令集SendCMD(0x0C);/0000,11
5、00 整体显示,游标off,游标位置offSendCMD(0x01);/0000,0001 清DDRAMSendCMD(0x02);/0000,0010 DDRAM地址归位SendCMD(0x80);/1000,0000 设定DDRAM 7位地址000,0000到地址计数器AC/SendCMD(0x04);/点设定,显示字符/光标从左到右移位,DDRAM地址加 一/SendCMD(0x0C);/显示设定,开显示,显示光标,当前显示位反白闪动/*清文本区*/void LcmClearTXT( void )unsigned char i;SendCMD(0x30); /8BitMCU,基本指令集合
6、SendCMD(0x80); /AC归起始位for(i=0;i64;i+)SendData(0x20);/*发送字符串*/void PutStr(unsigned char row,unsigned char col,unsigned char *puts)SendCMD(0x30); /8BitMCU,基本指令集合SendCMD(AC_TABLE8*row+col); /起始位置while(*puts != 0) /判断字符串是否显示完毕if(col=8) /判断换行 /若不判断,则自动从第一行到第三行col=0;row+;if(row=4) row=0; /一屏显示完,回到屏左上角Send
7、CMD(AC_TABLE8*row+col);SendData(*puts); /一个汉字要写两次puts+;SendData(*puts);puts+;col+;/*绘图*/void PutBMP(unsigned char *puts)unsigned int x=0;unsigned char i,j;SendCMD(0x34); /8Bit扩充指令集,即使是36H也要写两次SendCMD(0x36); /绘图ON,基本指令集里面36H不能开绘图for(i=0;i32;i+) /12864实际为256x32SendCMD(0x80|i); /行位置SendCMD(0x80); /列位置f
8、or(j=0;j32;j+) /256/8=32 byte /列位置每行自动增加SendData(putsx);x+;void ClearScreen() uchar i,j,x,y;LCDInit();SendCMD(0x3e);/ RE=1 扩展指令选择 G=1 开图形显示x=0x80;y=0x80;for(j=0;j64;j+)y=0x80;SendCMD(x);SendCMD(y);for(i=0;i32;i+)SendData(0x00);x=x+1;void Sendint(uint dd)SendData(dd8);SendData(dd);/*打点 x=0:128; y=0:6
9、4;*/void Gra(uchar x,uchar y)uchar xx,yy;SendCMD(0x34);SendCMD(0x36);xx=x/16;yy=63-y;if(yy=32)xx=xx+8;yy-=32;SendCMD(0x80+yy);SendCMD(0x80+xx);Sendint(0x8000(x%16);uchar code IBM=0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0x87,0xFF,0xFF,0xFF,0xF0,0
10、x00,0xFF,0xFF,0xE0,0x00,0x07,0xFF,0xFE,0x7F,0xFF,0xFF,0x87,0xFF,0xFF,0xFF,0xF0,0x00,0xFF,0xFF,0xE0,0x00,0x0F,0xFF,0xFE,0x7F,0xFF,0xFF,0x87,0xFF,0xFF,0xFF,0xF8,0x00,0xFF,0xFF,0xE0,0x00,0x0F,0xFF,0xFE,0x7F,0xFF,0xFF,0x87,0xFF,0xFF,0xFF,0xFC,0x00,0xFF,0xFF,0xF0,0x00,0x1F,0xFF,0xFE,0x00,0x00,0x00,0x00,0
11、x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
12、x7F,0xFF,0xFF,0x87,0xFF,0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xF8,0x00,0x3F,0xFF,0xFE,0x7F,0xFF,0xFF,0x87,0xFF,0xFF,0xFF,0xFF,0x80,0xFF,0xFF,0xFC,0x00,0x7F,0xFF,0xFE,0x7F,0xFF,0xFF,0x87,0xFF,0xFF,0xFF,0xFF,0x80,0xFF,0xFF,0xFC,0x00,0x7F,0xFF,0xFE,0x7F,0xFF,0xFF,0x87,0xFF,0xFF,0xFF,0xFF,0x80,0xFF,0xFF,0xFC,0
13、x00,0x7F,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 单片机 采用 串行 方式 LCD12864 驱动
链接地址:https://www.31ppt.com/p-4938639.html