LoginSignup
2
2

More than 5 years have passed since last update.

Raspberry Pi > I2C > clock stretching機能付きslave deviceへの対応 > link

Last updated at Posted at 2018-07-12
動作環境
Raspberry Pi 2 Model B (以下RPi2)
Raspbian Jessie
gcc (Raspbian 4.9.2-10) 4.9.2
とあるI2Cセンサー

I2Cのslave deviceにおいてclock stretching機能を持つ製品がある。

clock stretchingにおいてはSCLがlowにholdされる状態になる。
masterであるRPi2でSCLがlowを認識出ればいいが、RPi2のbcmチップセットではバグにより認識できないとのこと。
http://www.advamation.com/knowhow/raspberrypi/rpi-i2c-bug.html

対応方法としては「baudrateをlowestにする」こと。

参考1

You can slow down the whole I2C bus so that perhaps your attached device may be able to complete tasks within longer clock times.

/boot/config.txtへの設定例がある。

また、コマンドでのon the flyでの設定方法も紹介されている。

参考2

Generally use the lowest you can to mitigate the clock stretching bug, if your device supports clock stretching. (these eeproms dont)

懸念

clock stretchingの期間が12msecから150msecというようなslave deviceの場合、baudrateは3Hzなどになる。

ソフトウェアI2C実装で対応するなどの工夫が必要かもしれない。

参考3

In order to workaround this, I set data rate in I2C slave module higher. The communication rate is 400 kbps, but I set the data rate 1000 kbps. It worked for me.

baudrateを小さくするのでなく大きくすることで対処。

関連

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2