第十章单片机典型模块应用描述.ppt

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
实验原理——内部结构及基本特性 ZY12864D 是一种图形点阵液晶显示器,它主要由行驱动器/列驱动器及12864 全点阵液晶显示器组成,可完成图形显示,也可以显示8x4 个(16x16 点阵)汉字。 上图IC1为行驱动器。IC2、IC3为列驱动器,IC2控制左半屏,IC3控制右半屏。 程序: #include AT89X52.H #include stdio.h #include absacc.h unsigned char code table[]={0x3f,0x06,0x5b,0x4f,0x66, 0x6d,0x7d,0x07, 0x7f,0x6f}; unsigned char sec; //定义计数值,每过1 秒,sec 加1 unsigned int tcnt; //定时中断次数 bit write=0; //写24C08 的标志; sbit gewei=P1^3; //个位选通定义 sbit shiwei=P1^2; //十位选通定义 /////////24C08 读写驱动程序开始//////////////////// sbit scl=P3^6; // 24c08 SCL sbit sda=P3^7; // 24c08 SDA void delay1(unsigned char x) { unsigned int i; for(i=0;ix;i++); ;} void flash() //延时2us { ; ; } void x24c08_init() //24c08 初始化子程序 { scl=1;flash();sda=1;flash(); } void start() //启动I2C 总线 { sda=1;flash();scl=1;flash();sda=0;flash();scl=0;flash(); } void stop() //停止I2C 总线 { sda=0;flash( );scl=1;flash();sda=1;flash(); } void writex(unsigned char j) //写一个字节 { unsigned char i,temp; temp=j; for (i=0;i8;i++) { temp=temp1;scl=0;flash();sda=CY;flash();scl=1;flash(); } scl=0;flash();sda=1;flash(); } unsigned char readx( ) //读一个字节 { unsigned char i,j,k=0; scl=0;flash( );sda=1; for (i=0;i8;i++) { flash( );scl=1;flash( ); if (sda==1) j=1; else j=0; k=(k1)|j;scl=0; } flash();return(k); } void clock( ) // I2C 总线时钟,确认应答信号 { unsigned char i=0; scl=1;flash( ); while ((sda==1)(i255))i++; scl=0; flash( ); } ////////从24c08 的地址address 中读取一个字节数据///// unsigned char x24c08_read(unsigned char address) { unsigned char i; //先发写命令、写地址 start( );writex(0xa0);clock( );writex(address);clock( ); //再发读命令,读数据 start( );writex(0xa1);clock( );i=readx( ); stop( );delay1(10); return(i); } //////向24c08 的address 地址中写入一字节数据info///// void x24c08_write

文档评论(0)

4477769 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档