I have to correct me, I'm getting 128, not 255...

--- In [email protected], "mayer_to" <finalnot...@...> wrote:
>
> Hi guys,
> I have a few problems to get a PCF8591 working. The problem is that it seems 
> that the I2C communication works (no I2C_WRITE or I2C_READ errors), but I 
> can't get the analog inputs from the IC back.
> All I get is the value 255.
> 
> I'm also a bit confused, because if I understand the datasheet correctly it 
> states that the address-lsb is used to set the IC in read- or write-mode. But 
> if I look on the I2C example on http://foxlx.acmesystems.it/ it uses only one 
> address for a read and a write operation?
> 
> Do I interpret the datasheet wrong?
> How would an AD-conversion I2C-transfer look like?
> Does the example really work? Because I also get nonsense output if I use the 
> example on the webpage with my board. 
> 
> Here the example from the foxboard webpage.
> 
> // PCF8591 address scheme
> // | 1 | 0 | 0 | 1 | A2 | A1 | A0 | R/W |
> i2c_d.slave =(0x09<<4)|(0x01<<1);
> for (ch=0;ch<=3;ch++) {
> // Select the A/D channel
> i2c_d.wbuf[0] = ch;
> i2c_d.wlen = 1;
> if ((rtc=ioctl(fd_i2c,_IO( ETRAXI2C_IOCTYPE, I2C_WRITE),  
> &i2c_d))!=EI2CNOERRORS) {
> close(fd_i2c);
> printf( "Error %d on line %d\n",rtc,__LINE__);
> return ( -1 );
> }
> i2c_d.rlen = 3;
> if ((rtc=ioctl(fd_i2c,_IO( ETRAXI2C_IOCTYPE, I2C_READ), 
> &i2c_d))!=EI2CNOERRORS) {
> close(fd_i2c);
> printf( "Error %d on line %d\n",rtc,__LINE__);
> return ( -1 );
> } 
> 
> I really hope someone can help me out...
>


Reply via email to