单片机应用开发 LCD造字 3-1-4 字符型LCD.pptVIP

  • 10
  • 0
  • 约2.36千字
  • 约 11页
  • 2020-08-29 发布于北京
  • 举报

单片机应用开发 LCD造字 3-1-4 字符型LCD.ppt

Application and Development of Microcontroller 《单片机应用开发》课程 主讲教师 刘德新 移动通信技术专业教学资源库 深圳信息职业技术学院电子与通信学院 字符型LCD (四) 目录 01 字符型LCD的应用 单片机与字符型LCD的连接 EDITED BY LIU DEXIN * 单片机应用开发 EDITED BY LIU DEXIN * 单片机应用开发 单片机与字符型LCD的初始化程序 假设: 写指令的地址为0x5ffc 读状态的地址为0x5ffd 写数据的地址为0x5ffe 读数据的地址为0x5fff void command_send(uchar y) { while(ReadComm0x80!=0x80); WriteComm=y; } #define WriteComm XBYTE[0x5ffc] #define ReadComm XBYTE[0x5ffd] #define WriteData XBYTE[0x5ffe] #define ReadData XBYTE[ 0x5fff] 将LCD的工作模式初始化程序为: void initial_lcd(void) { command_send(0x38); //命令为0x38 command_send(0x0e); //命令为0x0e command_send(0x06); //命令为0x06 command_send(0x01); //命令为0x01 } EDITED BY LIU DEXIN * 单片机应用开发 单片机与字符型LCD的初始化程序 void command_send(uchar y) { while(ReadComm0x80!=0x80); ReadComm=y; } 本程序是延时程序,等待单片机将字符写入到LCD中,这种方法采用的是读取LCD的忙信号,当LCD忙时,读入的字节最高位为1,否则为0;还有一种写法就是延时程序用延时,延时的时间大约为1ms,最长为1.6ms,所以一般用延时2ms void command_send(uchar y) { delay(2); ReadComm=y; } EDITED BY LIU DEXIN * 单片机应用开发 单片机与字符型LCD的简单应用 #include reg52.h #include absacc.h #define uchar unsigned char #define uint unsigned int #define WriteComm XBYTE[0x5ffc] #define ReadComm XBYTE[0x5ffd] #define WriteData XBYTE[0x5ffe] #define ReadData XBYTE[ 0x5fff] void SendCommand(uchar); void SendData(uchar); void InitLCD(void); void delay(uchar); void main(void) { uchar ch=‘A’; delay(10); InitLCD(); while(1) { SendCommand(0x82); SendData(ch); ch++; if(ch==‘Z’+1) ch=‘A’; delay(255);delay(255);delay(255); } } EDITED BY LIU DEXIN * 单片机应用开发 单片机与字符型LCD的简单应用 void InitLCD(void) { SendCommand(0x38); //命令为0x38 SendCommand(0x0e); //命令为0x0e SendCommand(0x06); //命令为0x06 SendCommand(0x01); //命令为0x01 } void SendCommand(uchar y) { delay(2); WriteComm=y; } void SendData(uchar y) {

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档