From: zudil <su...@gm...> - 2012-05-18 18:00:09
|
I am trying to read data from http://www.upgradeindustries.com/media/files/products/ti-adc-ads7830.pdf ADS7830 in my overo using i2c. I used a http://www.ti.com/lit/ds/symlink/pca9306.pdf level-translator in between. According to datasheet, address byte is 1 0 0 1 0 a1 a2 r/w should be followed by command byte (channel and mode selection). I have a problem that there is no communication between gumstix and the device. I dont know where is the mistake is. My code is #include <stdint.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <linux/i2c-dev.h> /* for I2C_SLAVE */ #include <errno.h> int main(void) { int fh; uint8_t data = 0x84; fh = open("/dev/i2c-3", O_RDWR); if (fh < 0) { perror("open"); return 1; } // tell the driver we want the device at address 0b1001000 ioctl(fh, I2C_SLAVE, 0x48); // write 0x84 ( 1000 0100 - command byte to read from channel one) write(fh, data, 1); // read output from device read(fh, data, 1); printf("%x", data); close(fh); return 0; } output is always 84, even if I don't connect my device to gumstix. I am able to see some fluctuation in SDA and SCL lines when I run the program. -- View this message in context: http://gumstix.8.n6.nabble.com/i2c-in-overo-tp4964358.html Sent from the Gumstix mailing list archive at Nabble.com. |