欢迎来到天天文库
浏览记录
ID:52909557
大小:87.00 KB
页数:15页
时间:2020-03-31
《结合PROTEUS仿真的12864液晶显示程序文档.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、在proteus上用51单片机控制12864液晶显示2008-12-2016:23经过半天的努力,终于在PROTEUS上让液晶屏显出汉字了以下是源代码/*******************************main.h******************************/#ifndef_MAIN_H#define_MAIN_H#include#defineLcdDataPortP2 //数据端口#ifndefUCHAR_DEF#defineUCHAR_DEFtypedefunsignedcharuchar;#endifsbitR
2、eset=P3^0; //复位sbitRS=P3^1; //指令数据选择sbitE=P3^2; //指令数据控制sbitCS1=P3^4; //左屏幕选择,低电平有效sbitCS2=P3^5; //右屏幕选择sbitRW=P3^3; //读写控制sbitbusy=P2^7; //忙标志voidSetOnOff(ucharonoff); //开关显示voidSelectScreen(ucharscreen);//选择屏幕voidClearScreen(ucharscreen); //清屏voidShow1616(ucharlin,ucharco
3、lum,uchar*address);//显示一个汉字voidCheckState(); //判断状态voidLcdDelay(unsignedinttime);//延时voidWriteData(uchardat);//写数据voidSendCommand(ucharcommand);//写指令voidSetLine(ucharline); //置行地址voidSetColum(ucharcolum);//置列地址voidSetStartLine(ucharstartline);//置显示起始行voidInitLcd(); //初始化voidResetLc
4、d(); //复位#endif/*********************************************************************//***********************************lcd.c****************************************/#include"main.h"voidCheckState(){ E=1; RS=0; RW=1; LcdDataPort=0xff; while(!busy);}voidLcdDelay(unsignedinttime){ wh
5、ile(time--);}voidWriteData(uchardat){ CheckState(); E=1; RS=1; RW=0; LcdDataPort=dat; E=0;}voidSendCommand(ucharcommand){ CheckState(); E=1; RW=0; RS=0; LcdDataPort=command; E=0;}voidSelectScreen(ucharscreen) //0-全屏,1—左屏,2-右屏{ switch(screen) { case0: CS1=0; LcdDelay(2); CS2=1;
6、 LcdDelay(2); break; case1: CS1=1; LcdDelay(2); CS2=0; LcdDelay(2); break; case2: CS1=0; LcdDelay(2); CS2=0; LcdDelay(2); break; }}voidClearScreen(ucharscreen) //screen0-全屏,1—左屏,2-右屏{ uchari,j; SelectScreen(screen); for(i=0;i<8;i++) { SetLine(i); SetColum(0)
7、; for(j=0;j<64;j++) WriteData(0); }}voidSetLine(ucharline) //line->0:7{ line=line&0x07; line=line
8、0xb8; //10111xxx SendCommand(line);}voidSetColum(ucharcolum) //colum->0:63{ colum=colum&0x3f; colum=colum
9、0x40; //01xxxxxx SendCommand(colum);}voidSetStartLine(ucharstartline)//start
10、line-
此文档下载收益归作者所有