1602串行控制(配合74HC164)_第1页
1602串行控制(配合74HC164)_第2页
1602串行控制(配合74HC164)_第3页
1602串行控制(配合74HC164)_第4页
1602串行控制(配合74HC164)_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

5252 系列单片机之串行控制系列单片机之串行控制 LCD1602LCD1602 2010 09 02 17 52 串行控制 LCD1602 原理图 注 由于使用 74HC164 故不能读出命令 即不能判忙 采用延时处理 include 头文件 include define uchar unsigned char define uint unsigned int sbit RS P2 4 定义 I O 的硬件接口 sbit RW P2 5 sbit E P2 6 定义 I O 的硬件接口 sbit A B P2 2 定义 I O 的硬件接口 数据 sbit CP P2 3 定义 I O 的硬件接口 时钟 unsigned char code blog adr china unsigned char code email Julian unsigned char code zimo 0 x00 0 x08 0 x0F 0 x12 0 x0F 0 x0A 0 x1F 0 x02 年 0 x00 0 x0F 0 x09 0 x0F 0 x09 0 x0F 0 x09 0 x13 月 0 x00 0 x1F 0 x11 0 x11 0 x1F 0 x11 0 x11 0 x1F 日 uS 延时函数 void DelayUs2x unsigned char t while t mS 延时函数 void DelayMs unsigned char t while t 大致延时 1mS DelayUs2x 245 DelayUs2x 245 函数功能 LCD1602 写指令 void write Directive uchar a 写指令 uchar i DelayUs2x 5 RS 0 RW 0 for i 0 i 8 i if a else A B 0 CP 0 DelayUs2x 2 CP 1 CP 0 a a 1 先将指令移位转换为串行数据 E 0 DelayUs2x 5 E 1 函数功能 LCD1602 写数据 void write Data uchar a 写数据 uchar i DelayUs2x 5 RS 1 RW 0 for i 0 i 8 i if a else A B 0 CP 0 DelayUs2x 2 CP 1 CP 0 a a 1 E 0 DelayUs2x 5 E 1 函数功能 LCD1602 初始化 void lcd1602init 初始化 write Directive 0 x38 DelayMs 5 write Directive 0 x38 DelayMs 5 write Directive 0 x38 DelayMs 1 write Directive 0 x08 显示关闭 DelayMs 1 write Directive 0 x01 清屏 DelayMs 1 write Directive 0 x02 归位 AC 0 DelayMs 1 write Directive 0 x06 DelayMs 1 write Directive 0 x0c DelayMs 1 按指定位置显示一个字符 void DisplayOneChar unsigned char X unsigned char Y unsigned char DData Y X 限制 X 不能大于 15 Y 不能大于 1 if Y X 0 x40 当要显示第二行时地址码 0 x40 X 0 x80 算出指令码 DelayUs2x 10 write Directive X DelayMs 1 write Data DData write Directive X DelayMs 1 按指定位置显示一串字符 void Displaystr unsigned char X unsigned char Y unsigned char code DData unsigned char ListLength ListLength 0 Y X 限制 X 不能大于 15 Y 不能大于 1 while DData ListLength 0 若到达字串尾则退出 if X 16 X 0 Y if Y 2 Y 0 else X 0 Y if Y 2 Y 0 生成自定义字符 void Write CGRAM unsigned char p unsigned char i j kk unsigned char tmp 0 x40 操作 CGRAM 的命令码 kk 0 for j 0 j 3 j for i 0 i 8 i 8 个字节生成 1 个字符点阵 DelayUs2x 100 write Directive tmp i 操作 CGRAM 的命令码 写入 CGRAM 地址 DelayUs2x 2 write Data p kk 写入数据 kk tmp 8 void main lcd1602init Write CGRAM zimo Displaystr 0 0 blog adr Displaystr 6 0 email Displaystr 0 1 2011 Disp

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论