What device are you using? Is it 3.3V kompatible? Check the following: -Do you use the right pins? Pin 1 is located near the 5V jack and not on the USB side. (see my photo for i2c-1) -Don't mess up with SCL and SDA -Is your device 3.3V compatible? If not you need a level shifter. -Put two pull up resistors to SCL and SDA if your device doesn't provide them. i2c.jpg <https://docs.google.com/file/d/0By1EWMh-3Gq7TTZPcDNyaDJ6Y3c/edit?usp=drive_web>
2014-12-15 6:57 GMT+01:00 <[email protected]>: > > Hi everyone, > > I tried i2c communication with p9_17 and p9_18 with /dev/i2c-0 and > /dev/i2c-1. > I got same error in both cases: Remote I/O error. > But my ioctl() function is working and i got '0' return value(success). > Now i am confused with pull up resistors. Is it necessary to pull up > p9_17 and p9_18 line to Vdd? > I know that there is internal pull up resistors present in BBB. Is this > not available for two enabled i2c buses? > How to enable all the three i2c buses? > Can I choose i2c1 and i2c2 for communication? > When I connected my slave board to BBB(p9_17 and p9_18) and checked the > command 'i2cdetect -r 1' > I got : > > root@beaglebone:~# i2cdetect -r 1 > WARNING! This program can confuse your I2C bus, cause data loss and worse! > I will probe file /dev/i2c-1 using read byte commands. > I will probe address range 0x03-0x77. > Continue? [Y/n] y > 0 1 2 3 4 5 6 7 8 9 a b c d e f > 00: -- -- -- -- -- -- -- -- -- -- -- -- -- > 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > 50: -- -- -- -- UU UU UU UU -- -- -- -- -- -- -- -- > 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > 70: -- -- -- -- -- -- -- -- > > > for 'i2cdetect -r 0 ' i got > > root@beaglebone:~# i2cdetect -r 0 > WARNING! This program can confuse your I2C bus, cause data loss and worse! > I will probe file /dev/i2c-0 using read byte commands. > I will probe address range 0x03-0x77. > Continue? [Y/n] y > 0 1 2 3 4 5 6 7 8 9 a b c d e f > 00: -- -- -- -- -- -- -- -- -- -- -- -- -- > 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > 20: -- -- -- -- UU -- -- -- -- -- -- -- -- -- -- -- > 30: -- -- -- -- UU -- -- -- -- -- -- -- -- -- -- -- > 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > 50: UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > 70: UU -- -- -- -- -- -- -- > > > I am waiting for your great opinions. > > > On Thursday, December 11, 2014 11:39:35 AM UTC+5:30, [email protected] > wrote: > >> Hi, >> >> I am trying to read two bytes of data from a board(slave) using >> BBB(master) through i2c interface. >> >> I connected my board's SDA and SCL lines to P9_18 and P9_17 of BBB >> respectively. >> >> My code is >> >> #include <stdio.h> >> #include <errno.h> >> #include <string.h> >> #include <fcntl.h> >> #include <stdlib.h> >> #include <unistd.h> >> #include <linux/i2c-dev.h> >> #include <sys/ioctl.h> >> >> >> int main() >> { >> int fd,i; >> int addr = 0x43; >> char buffer[10] = {0}; >> >> fd = open("/dev/i2c-1", O_RDWR); // opening i2c-1 file. returns a file >> descriptor used by read >> if(fd < 0) >> { >> printf("i2c failed to open\n"); >> } >> >> if(ioctl(fd, I2C_SLAVE, addr) < 0) >> printf("failed to acquire bus\n"); >> >> if(read(fd,buffer,2) != 2) //reading 2 bytes of data >> { >> printf("i2c read failed\n"); >> >> } >> else >> { >> for(i=0;i<2;i++) >> printf("the data is %d \n",buffer[i]); >> } >> >> >> return 0; >> } >> >> >> >> >> >> >> I got output --- "i2c read failed" >> >> What is the problem in my code? Or any problem in hardware? When I >> checked the following command, I got output like >> >> root@beaglebone:~# i2cdetect -l >> i2c-0 i2c OMAP I2C adapter I2C >> adapter >> i2c-1 i2c OMAP I2C adapter I2C >> adapter >> root@beaglebone:~# ls -l /sys/bus/i2c/devices/i2c-* >> lrwxrwxrwx 1 root root 0 Jan 1 2000 /sys/bus/i2c/devices/i2c-0 -> >> ../../../devices/ocp.3/44e0b000.i2c/i2c-0 >> lrwxrwxrwx 1 root root 0 Jan 1 2000 /sys/bus/i2c/devices/i2c-1 -> >> ../../../devices/ocp.3/4819c000.i2c/i2c-1 >> >> >> Can anyone find problem? Please reply. >> > -- > For more options, visit http://beagleboard.org/discuss > --- > You received this message because you are subscribed to the Google Groups > "BeagleBoard" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
