GPIO引脚模拟I2C通信的驱动设计

韩勇, 张芬, 魏进松, 于涛

集成电路与嵌入式系统 ›› 2024, Vol. 24 ›› Issue (4) : 82-87.

PDF(1680 KB)
PDF(1680 KB)
集成电路与嵌入式系统 ›› 2024, Vol. 24 ›› Issue (4) : 82-87. DOI: 10.20193/j.ices2097-4191.2024.04.015
研究论文

GPIO引脚模拟I2C通信的驱动设计

作者信息 +

Driver design for simulating I2C communication based on GPIO pins

Author information +
文章历史 +

摘要

I2C总线多用于嵌入式系统中多个芯片及模块间的数据通信,针对芯片的I2C总线专用引脚被占用或I2C总线功能需移植到其他平台等需求,现有的I2C总线专用引脚使用方式存在一定的局限性。本文基于I2C总线的通信机理开发了一套驱动程序,通过控制常规GPIO引脚电平模拟I2C时序,实现I2C总线通信功能。以STM32F103C8T6芯片为I2C总线主控制器、PCF8591T A/D转换模块为I2C总线从器件,对开发的I2C驱动程序进行验证,试验结果表明,该驱动方式可靠、稳定。

Abstract

The I2C bus is widely employed for exchanging data between multiple chips and modules in embedded systems.However,the utilization of dedicated I2C bus pins has limitations when these pins are already occupied or when the I2C bus function needs to be migrated to other platforms.In the study,a driver program is developed that leverages the communication mechanism of the I2C bus.It achieves I2C bus communication functionality by simulating I2C timing through the control of electrical levels on conventional GPIO pins.The STM32F103C8T6 chip serves as the primary controller of the I2C bus,while the PCF8591T A/D conversion module operates as the slave device.This article verifies the developed I2C driver program,and the experimental results show that the driving method is reliable and stable.

关键词

I2C总线 / GPIO引脚 / 驱动 / STM32 / PCF8591T

Key words

I2C bus / GPIO pin / drive / STM32 / PCF8591T

引用本文

导出引用
韩勇, 张芬, 魏进松, . GPIO引脚模拟I2C通信的驱动设计[J]. 集成电路与嵌入式系统. 2024, 24(4): 82-87 https://doi.org/10.20193/j.ices2097-4191.2024.04.015
HAN Yong, ZHANG Fen, WEI Jinsong, et al. Driver design for simulating I2C communication based on GPIO pins[J]. Integrated Circuits and Embedded Systems. 2024, 24(4): 82-87 https://doi.org/10.20193/j.ices2097-4191.2024.04.015
中图分类号: TP311.1 (程序设计)   

参考文献

[1]
何立民. I2C总线应用系统设计[M]. 北京: 北京航空航天大学出版社, 1995.
HE L M. Design of I2C Bus Application System[M]. Beijing: Beihang University Press, 1995. (in Chinese)
[2]
邓忠华, 李霞, 陈浩. I2C总线技术在单片机串行扩展中的应用[J]. 武汉理工大学学报(交通科学与工程版), 2005, 29(2):227-229,247.DOI:10.3963/j.issn.2095-3844.2005.02.018.
DENG ZH H, LI X, CHEN H. Application of I2C Bus Technology in Serial Expansion of Microcontrollers[J]. Journal of Wuhan University of Technology (Transportation Science and Engineering Edition),2005, 29(2):227-229,247.DOI:10.3963/j.issn.2095-3844.2005.02.018. (in Chinese)
[3]
李国良, 熊小萍, 刘萍. 单主系统中I2C总线的虚拟技术[J]. 贵州工业大学学报(自然科学版), 2004, 33(2):4.DOI:CNKI:SUN:GZGX.0.2004-02-011.
LI G L, XIONG X P, LIU P. Virtual Technology of I2C Bus in Single Host Systems[J]. Journal of Guizhou University of Technology:Natural Science Edition, 2004, 33(2):4.DOI:CNKI:SUN:GZGX.0.2004-02-011. (in Chinese)
[4]
刘鲁兵. 基于MCU的I2C总线控制器的设计与验证[D]. 西安: 西安电子科技大学, 2020.DOI:10.27389/d.cnki.gxadu.2020.001890.
LIU L B. Design and Verification of I2C Bus Controller Based on MCU[D]. Xi'an: Xidian University, 2020.DOI:10.27389/d.cnki.gxadu.2020.001890. (in Chinese)
[5]
宣慧, 孙佳昊, 程实, 等. 基于I2C总线实验设计[J]. 实验技术与管理, 2020, 37(1):52-55.DOI: 10.16791/j.cnki.sjg.2020.01.014.
XUAN H, SUN J H, CHENG SH, et al. Experimental Design Based on I2C Bus[J]. Experimental Technology and Management, 2020, 37(1):52-55.DOI:10.16791/j.cnki.sjg.2020.01.014. (in Chinese)
[6]
赵国栋, 郭锋, 周洋. 国产嵌入式操作系统的I2C驱动设计与实现[J]. 电脑编程技巧与维护, 2023(1):56-58.DOI:10.16184/j.cnki.comprg.2023.01.009.
ZHAO G D, GUO F, ZHOU Y. Design and Implementation of I2C Driver for Domestic Embedded Operating Systems[J]. Computer Programming Skills and Maintenance, 2023(1):56-58.DOI:10.16184/j.cnki.compress.2023.01.009. (in Chinese)
[7]
李耀川. I2C控制器及加速度传感器的驱动设计和实现[D]. 西安: 西安电子科技大学, 2013.
LI Y CH. Design and Implementation of I2C Controller and Acceleration Sensor Drive[D]. Xi'an: Xidian University, 2013. (in Chinese)
[8]
石宗义. I2C总线时序分析及其模拟[J]. 太原理工大学学报, 2004, 35(1):4.DOI:10.3969/j.issn.1007-9432.2004.01.016.
SHI Z Y. Analysis and Simulation of 2C Bus Timing[J]. Journal of Taiyuan University of Technology, 2004, 35(1):4. DOI:10.3969/j.issn.1007-9432.2004.01.016. (in Chinese)
[9]
NXP Semiconductors.PCFSemiconductors.PCF 8591 datasheet, 2013.
[10]
STMicroelectronics. STM32F103xx advanced Arm-based 32-bit MCUs Reference Manual, 2021.
[11]
南山府嵌入式. 玩转STM32之IIC通信(软件模拟篇)[EB/OL].(2022-11-02)[2023-10-16]. https://zhuanlan.zhihu.com/p/579536577.
Embedded in Nanshan Prefecture. Playing STM32 with I2C Communication (Software Simulation Chapter)[EB/OL].(2022-11-02)[2023-10-16]. https://zhuanlan.zhihu.com/p/579536577. (in Chinese)
[12]
赵道新, 李炳辰. 基于PCF8591的I2C总线多路温度测量系统[J]. 制造业自动化, 2013, 35(5):3.DOI: 10.3969/j.issn.1009-0134.2013.03(s).11.
ZHAO D X, LI B CH. I2C bus multi-channel temperature measurement system based on PCF8591[J]. Manufacturing Automation, 2013, 35(5):3.DOI:10.3969/j.issn.1009-0134.2013.03(s).11. (in Chinese)
[13]
周剑利, 郭建波, 崔涛. 具有I2C总线接口的A/D芯片PCF8591及其应用[J]. 微计算机信息, 2005(7):150-151.
ZHOU J L, GUO J B, CUI T. A/D chip PCF8591 with I2C bus interface and its application[J]. Microcomputer Information, 2005(7):150-151. (in Chinese)
[14]
陈柱峰, 沈治国. 基于PCF8591的I2C总线A/D、D/A转换[J]. 企业技术开发, 2009, 28(5):24-27.
CHEN ZH F, SHEN ZH G. I2C Bus A/D, D/A Conversion Based on PCF8591[J]. Enterprise Technology Development, 2009, 28(5):24-27. (in Chinese)
[15]
郝结来, 王子权, 林华. 基于STM32的多通道温湿度测量仪设计[J]. 电子设计工程, 2021, 29(11):74-79.DOI: 10.14022/j.issn1674-6236.2021.11.016.
HAO J L, WANG Z Q, LIN H. Design of a multi-channel temperature and humidity measurement instrument based on STM32[J]. Electronic Design Engineering, 2021, 29(11):74-79.DOI:10.14022/j.issn1674-6236.2021.11.016. (in Chinese)
[16]
杨日容, 林木峰, 陆泉森. 一种基于I2C总线驱动的锅炉温度测量系统设计[J]. 微型机与应用, 2011, 30(19):73-75.DOI:10.3969/J.ISSN.1674-7720.2011.19.026.
YANG R R, LIN M F, LU Q S. Design of a Boiler Temperature Measurement System Driven by I2C Bus[J]. Microcomputers and Applications, 2011, 30(19):73-75.DOI:10.3969/j.issn.1674-7720.2011.19.026. (in Chinese)

编辑: 薛士然
PDF(1680 KB)

Accesses

Citation

Detail

段落导航
相关文章

/