Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i2c-gpio module has the problem of slow response #1467

Closed
FishTest opened this issue May 11, 2016 · 3 comments
Closed

i2c-gpio module has the problem of slow response #1467

FishTest opened this issue May 11, 2016 · 3 comments

Comments

@FishTest
Copy link

FishTest commented May 11, 2016

When I enable devictree i2c-gpio in /boot/config.txt , after run sudo i2cdetect -y 3 , the response is very slow , about 1 second each scan when display '--'.

pi@raspberrypi:~ $ sudo i2cdetect -y 3
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- ^Cpi@raspberrypi:~ $

pi@raspberrypi:~ $ cat /boot/config.txt | grep i2c-gpio
dtoverlay=i2c-gpio

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.4.9-v7+ #884 SMP Fri May 6 17:28:59 BST 2016 armv7l GNU/Linux

Tested On PI2 and PI3

What could be the causes ?

@6by9
Copy link
Contributor

6by9 commented May 11, 2016

Have you left the SCL line either floating or with a pull down? If so then the driver will be doing clock stretching on every bit.
Looking at https://github.com/raspberrypi/linux/blob/rpi-4.4.y/drivers/i2c/busses/i2c-gpio.c#L208 there appears to be a 100ms per bit timeout, so 1sec total sounds plausible for each transaction from i2c-detect.

@6by9
Copy link
Contributor

6by9 commented May 11, 2016

30 second test doing as you reported.

Add the dtoverlay - defaults to using GPIOs 23&24. i2cdetect -y 3 takes a long time.

sudo raspi-gpio set 23 pu
sudo raspi-gpio set 23 pu

and i2cdetect -y 3 completes very quickly with all dashes. So my guess looks to be correct - you have no pullups.
Do not rely on the SoC internal pullups if you want reliable I2C - use external ones.

@FishTest
Copy link
Author

FishTest commented May 12, 2016

Thank you very much!
everything go back after
pi@raspberrypi:~ $ sudo raspi-gpio set 23 pu
pi@raspberrypi:~ $ sudo raspi-gpio set 24 pu
pi@raspberrypi:~ $ sudo i2cdetect -y 3
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- 3c -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
pi@raspberrypi:~ $

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants