MEGA8单片机对LCD1602液晶屏的驱动.doc

上传人:白大夫 文档编号:3256129 上传时间:2019-08-06 格式:DOC 页数:3 大小:19.50KB
返回 下载 相关 举报
MEGA8单片机对LCD1602液晶屏的驱动.doc_第1页
第1页 / 共3页
亲,该文档总共3页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《MEGA8单片机对LCD1602液晶屏的驱动.doc》由会员分享,可在线阅读,更多相关《MEGA8单片机对LCD1602液晶屏的驱动.doc(3页珍藏版)》请在三一文库上搜索。

1、MEGA8单片机对LCD1602液晶屏的驱动调试过程总结一下:1)由于找不到的1620资料,不知道它的操作时序。看到一些帖子说1620和1602没区别,还是有点将信将疑。后面用网友编写的1602程序试验,才知道它们俩没啥区别2)关于是否检测LCD处于空闲,觉得还是最好在写指令和写数据时都加上。不检测,会导致显示结果不正常。3)由于连线很多14根(加上背光就是16根),如果有一根除了问题就会影响到显示。所以我是用万用表一根线一根线量了之后才通电试验的。4)看到很多帖子都建议在初始化LCD前延时几十毫秒。本例中并没有延时,显示也正常。5)总的说来,不是很难。在遇到问题时只要能够仔细分析,就能找出原

2、因和解决方法。自己前几天在试程序时就是显示结果不对,一直在检查自己的程序,没想到原来是单片机的Flash到寿命了那个郁闷啊。头文件中有五个函数:Function1.unsigned char AskBusy(void) 询问LCD1620是否空闲, 返回值“1”空闲, “0”为忙;FuncTIon2.WritEDAta(char data) 写数据到LCD1620;FuncTIon3.WriteCommand(char command) 写指令到LCD1620;FuncTIon4.PutOneCharLCD(x,y,*Disp) 在LCD1620上显示一个字符, x,y定义位置FuncTIon

3、5.PutStringLCD(a,b,*DispString) 在LCD1620上显示一个字符串, a,b定义初始位置。 Function6.LCD_Init() 初始化LCD在使用此头文件之前,必须有以下宏定义:#define DataPortPullup PORTx#define DataPortDirection DDRx#define ReadLCDPINPINx#defineCTRlPortPullup PORTx#define CtrlPortDirection DDRx#define RS_Bit Px?#define RW_Bit Px?#define E_Bit Px?其中“

4、x”代表B,C,D(mega8中无A口),“?”代表“01”完整头文件如下(解释搞了一大堆,也学学用英语):/*/* Project :1620 Display Headfile */* Date :2008,3,11 */* Author :lhy */* Version :v1.1 */* Rework :lhy */* Rework Date :2008.4.28 */* */* Comments : */* 1 Function Description */* Function1.unsigned char AskBusy(void) */* -Calls this Fun to as

5、k if LCD is busy, */* 1-free,0-busy; */* Function2.WritEDAta(char data) */* -Write data to LCD */* Function3.WriteCommand(char command) */* -write command to LCD */* Function4.PutOneCharLCD(x,y,*Disp) */* -Put one char to LCD. */* Function5.PutStringLCD(a,b,*DispString) */* -Put String to LCD. Max l

6、ength 32bits. */* */* 2 How to use */* Before use this HeadFile, */* need to define as below: */* #define DataPortPullup PORTx */* #define DataPortDirection DDRx */* #define ReadLCDPin PINx */* #define CtrlPortPullup PORTx */* #define CtrlPortDirection DDRx */* #define RS_Bit Px? */* #define RW_Bit Px? */* #define E_Bit Px? */* x - A,B,C,D.。. */* ? - 0,1,2,3,4,5,6,7 */* And set control port output,like this: */* CtrlPortDirection |= */* (1/* 3 Add the Function “LCD_Init(void)” */* Before this Fun, you must set control port */* output. */

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1