STM32_IIC协议编程

      最后更新:2022-05-23 14:36:21 手机定位技术交流文章

      目录

      前言

      IIC子函数

      IIC_Start

      IIC_Stop

      IIC_Wait_Ack

      IIC_ACK

      IIC_NACK

      IIC_Send_Byte

      IIC_Read_Byte

      AT24C02 分功能

      WriteOneByte

      ReadOneByte

      AT24C02_Check

      前言:

      在数据传输期间,I2C总线产生三种信号:启动信号、终端信号和响应信号。

      启动信号:SCL高,SDA从高向低,数据正在发送。

      终端信号:SCL高空,自失能系统从低到高到终端数据传输

      反应信号:收到8比特数据后,接收者IC将特定低高度脉冲传送到发送IC,信号接收。

      当SSCL是免费和高, 数据传输开始。

      SDA有一个低ACK(启动)和一个高NACK(停止)。

      IIC子函数

      IIC 启动和完成的前体
      START CONDITION: A high-to-low transition of SDA with SCL high is a start condition
      which must precede any other command

      SSL高空和自失能装置高到低转换是一个起始条件,必须先有任何其他命令。

      IIC_Start

      STOP CONDITION: A low-to-high transition of SDA with SCL high is a stop condition.
      After a read sequence, the stop command will place the EEPROM in a standby power
      mode。
      停止条件:在 SCL 将自失能装置从低到高转换为高是一个停止条件。停止指令,并在读取序列后将EEPROM置于备用动力模式中。

      IIC_Stop

      IIC_Wait_Ack

      ACKNOWLEDGE: All addresses and data words are serially transmitted to and from
      the EEPROM in 8-bit words. The EEPROM sends a “0” to acknowledge that it has
      received each word. This happens during the ninth clock cycle.
      ACKNODLATION: 将所有地址和数据单词传送到 EEPROM 时共使用了8个字串。 EEPROM 在第九钟周期内传送0个字,以表明它收到每个单词。
      等待应答信号
      等待应答信号

      ACK 和 NACK 信号

      ACKNOWLEDGE: All addresses and data words are serially transmitted to and from
      the EEPROM in 8-bit words. The EEPROM sends a “0” to acknowledge that it has
      received each word. This happens during the ninth clock cycle.
      ACKNODLATION: 将所有地址和数据单词传送到 EEPROM 时共使用了8个字串。 EEPROM 在第九钟周期内传送0个字,以表明它收到每个单词。
      因此,短链氯化石蜡从低升到高,自失能装置降低到ACK,自失能装置增加到NACK。
      等待应答信号
      第九个周期接收应答

      IIC_ACK

      IIC_NACK

      IIC_Send_Byte

      写数据时序图

      IIC_Read_Byte

      读数据时序图

      AT24C02 分功能

      WriteOneByte

      写时序

      写入指定长度的数据

      ReadOneByte

      读时序

      读取指定长度的数据

      AT24C02_Check

      在程序开始时,请检查硬件上是否有 AT24C02, 或它能否读写 。

      本文由 在线网速测试 整理编辑,转载请注明出处,原文链接:https://www.wangsu123.cn/news/25961.html

          热门文章

          文章分类