首页 » 信息技术 »

树莓派软IIC接口支持I2C clock stretching

2020年6月20日 / 1次阅读
树莓派

有一些设备需要使用I2C clock Stretching特性,而树莓派的hardware IIC接口不支持这个特性,在通信的时候,会出现Remote IO Error。

All variants of the Raspberry Pi have an I2C hardware bug which prevents I2C clock stretching from functioning correctly. A symptom of this bug is "remote I/O errors". To avoid this issue do not use I2C devices which stretch the I2C clock with a Raspberry Pi.

Configuring Software I2C on the Raspberry Pi

Raspbian has a software I2C driver that can be enabled by adding the following line to /boot/config.txt:

dtoverlay=i2c-gpio,bus=3

This will create an I2C bus called /dev/i2c-3. SDA will be on GPIO23 and SCL will be on GPIO24 which are pins 16 and 18 on the GPIO header respectively.

For further information about i2c-gpio and the parameters it supports see /boot/overlays/README on the Raspberry Pi.

The advantage of software I2C over hardware I2C on the Raspberry Pi is that software I2C supports I2C clock stretching. Hardware I2C doesn't support I2C clock stretching due to a hardware bug. (http://www.advamation.com/knowhow/raspberrypi/rpi-i2c-bug.html)

Some devices like the BNO055 9-axis absolute orientation sensor rely on I2C clock stretching and will not function correctly with hardware I2C on a Raspberry Pi. Using software I2C to communicate with the BNO055 will resolve this issue.

Another typical use case for software I2C is communication with AVR microcontrollers, for example, the ATmega328P microcontroller on an Arduino UNO. AVR microcontrollers are not particularly fast and it's relatively easy to implement AVR code that relies on I2C clock stretching. Using software I2C to communicate with the AVR will resolve I2C clock stretching issues.

先记录一下吧,至少可以让树莓派出2个IIC接口。

本文链接:https://www.maixj.net/ict/i2c-clock-stretching-23758

相关文章

留言区


前一篇:

-->只要几分钟回答问卷,就能轻松赚现金!

栏目精选

云上小悟,麦新杰的独立博客

Ctrl+D 收藏本页

栏目


©Copyright 麦新杰 Since 2014 云上小悟独立博客版权所有 备案号:苏ICP备14045477号-1。云上小悟网站部分内容来源于网络,转载目的是为了整合信息,收藏学习,服务大家,有些转载内容也难以判断是否有侵权问题,如果侵犯了您的权益,请及时联系站长,我会立即删除。

网站二维码
go to top