找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3374|回复: 0
打印 上一主题 下一主题
收起左侧

关于24c02系列IIC总线的研究

[复制链接]
跳转到指定楼层
楼主
ID:70941 发表于 2014-12-23 01:43 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    明确这样几条,就能正确理解IIC总线的原理:

1.      scl信号永远是由主机产生的。

2.      主机和从机都能作为发送端,也都能作为接收端

3.      主机在写数据的时候主机是发送端,从机是接收端,主机在读数据的时候从机是发送端,主机是接收端。

4.      在页写数据的时候会以8或16作为页写数据的个数,如果写入的数据超过这个数值那么先前写入的数据会被覆盖掉。

5.      在连续读的模式下数据的地址会一直增加下去,没有页读的8或16的限制。

6.      在SCL在高电平的时候DAT是不能变化的,否则这个变化会作为开始或结束的信号。根据这一条就可以断定,DAT数据的变化是在SCL为低电平的时候,也就能说明在向24C02写数据的时候写完8个数据之后的 那个下降沿会触发第9个应答位。这个应答位必须在SCL变为高电平之前就稳定下来,否则会被视为起始位或是结束位。同位的道理在读数据的时候,当24C02发完一个8位的数据之后,在之后的那个SCL的下降沿,单片机必须先将DAT变为高电然后才能将SCL拉为高电平,否则也会出现上面的问题也就是会被24C02视为起始位或是结束位。

7.      24C02芯片有一个TWR参数,就是两次写操作的最小时间间隔,这个时间因不同的芯片生产厂商有不同,一般两次写的时间间隔设定为10ms是足够的。

8.      关于24C02的页写入模式,我察看了一个24C02的数据手册对页写模式的摘写下来:Page Write. For the Page Writemode, the MODEpin must be at VIL. The Page Write mode allows upto 8 bytes to bewritten in a single  write cycle,providedthat they are all located in the same ’row’in the memory: that is the 5 mostsignificant mem-ory address bits (A7-A3) are the same. The mastersends from oneup to 8 bytes of data, which areeach acknowledged by the memory. After eachbyteis transfered, the internal byte address counter(3 least significant bits only)is incremented. Thetransfer is terminated by the master generating aSTOPcondition. Care must be taken to avoid ad-dress counter ’roll-over’ which couldresult in databeing overwritten. Note that, for any write mode,the generationby the master of the STOP conditionstarts the internal memory program cycle.All inputsare disabled until the completion of this cycle andthe memory willnot respond to any request.

这里说明页写模式下最多只能写入8个字节,如果写得超过8个字节,前面的数据就会被覆盖掉,这里就要注意写入24C02的基地址了,只能是8的整数倍了,而且也只能最多写入8个数据,这个在编写页写函数时要特注意。

当然对于不是24C02的芯片,比如24C04,或是容量更大的芯片,这个数据就不是8个了,有可能是16个,或是32个。

9.      关于24C02的顺序读的操作,是没有页的概念的,下面是摘于24C02的数据手册:

Sequential Read. This mode can be initiated witheither a Current Address Read or a Random Ad-dress Read. However, in this case the masterDOES acknowledge the data byte output and thememory continues to output the next byte in se-quence. To terminate the stream of bytes, themaster must NOT acknowledge the last byte out-put, but MUST generate a STOP condition. Theoutput data is from consecutive byte addresses,with the internal byte address counter automat-ically incremented after each byte output. After acount of the last memory address, the addresscounter will ’roll- over’ and the memory will continueto output data.

10.  应答是在SCL在低电平的时候将DAT拉为低电平,非应答是在SCL在低电平的时候将DAT拉为高电平,这是没有任何问题的,只是要区分,应答是主机发出的还是从机发出的,因为应答的一定是接收方,主机和从机都可能是接收方,但是这里注意非应答数据一定是主机发出的,从这一点可以看出主机和从机在逻辑上是不对称的。

评分

参与人数 1黑币 +1 收起 理由
zjvskn + 1 赞一个!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表