LoginSignup
0
2

More than 5 years have passed since last update.

Raspberry Pi | I2C > bug > clock stretching bug | sudo modprobe i2c-bcm2708 baudrate=400000で100000になる

Last updated at Posted at 2018-02-27
動作環境
Raspberry Pi 2 Model B (以下RPi)
Raspbian Jessie
Python 2.7.9
I2C接続のとあるセンサー

関連

bug

I2Cのセンサーへコマンドの書込みはできるが、データ取得に成功していない。

調べているうちに以下の情報を見つけた。
https://www.richud.com/wiki/Rasberry_Pi_I2C_EEPROM_Program

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

以下の対応方法も見つけた。
http://gaje.jp/2015/01/03/3051/

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. Here is the setup of I2C slave module.

modprobeコマンドでの設定

$ sudo modprobe -r i2c-bcm2708
$ sudo modprobe i2c-bcm2708 baudrate=400000
$ dmesg
...
[ 1591.469283] bcm2708_i2c 3f804000.i2c: BSC1 Controller at 0x3f804000 (irq 79) (baudrate 100000)

modprobeでbaudrate=400000としてもdmsgで表示されるのはbaudrate 100000

Pythonコードで動作確認

対象センサーのPython実装コードをGitHubで見つけた。
そのコードで動作確認できた。

ハードウェアとしては問題はないということだろう。

baudrateを100kHzにしても400kHzにしても測定値を取得できた。

0
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
0
2