I am writing a little "oscilloscope" program in c++ using /dev/fbx. I am reading in analog values via a pcf8591 connected to the I2C bus. Every thing works well if I only read 1 channel of analog data. But if I add in a 2nd channel the data gets messed up. There are a lot of extraneous 0 and 255 as well as data from one channel showing in the read from the other channel.
Here is a sample of what I am doing:
... part of an infinite loop ..
wiringPiI2CWrite(fd, 0x40 );
sig2 = wiringPiI2CRead(fd) - 100;
sig2 = wiringPiI2CRead(fd) - 100;
sig3 = (x & 0xff) / 2;
commented out---
wiringPiI2CWrite(fd, 0x43 );
sig3 = wiringPiI2CRead(fd) - 100;
sig3 = wiringPiI2CRead(fd) - 100;
commented out--
......................
This code works perfectly with channel 0... But when I uncomment the 3 lines for channel 3 the data gets messed up..
I've tried using the auto-increment function but the same problem. I does not matter what channel I use - only if I use more than 1 channel. I've also tried using long delays after each read and write but to no avail.
Any ideas out there??