pcf 8591 i2c bus basic stamp problem

Hi,

I'm trying to control a PCF8591 A/D Converter with my Basic Stamp 2p40 via I2C Bus. Bus is working as I can control a PCF8574 without problems.

Code is as follows:

I2COUT 8, I2CIdSharpsWrite, I2CSharpsControlByte00, [I2CSharpsControlByte00] I2CIN 8, I2CIdSharpsRead, 0, [B0] I2COUT 8, I2CIdSharpsWrite, I2CSharpsControlByte01, [I2CSharpsControlByte01] I2CIN 8, I2CIdSharpsRead, 0, [B1] I2COUT 8, I2CIdSharpsWrite, I2CSharpsControlByte10, [I2CSharpsControlByte10] I2CIN 8, I2CIdSharpsRead, 0, [B2] I2COUT 8, I2CIdSharpsWrite, I2CSharpsControlByte11, [I2CSharpsControlByte11] I2CIN 8, I2CIdSharpsRead, 0, [B3]

The Constants are correctly defined elsewhere. Now the problem is that all read values contain the result of the AN0-Port of the Device. No other result is read.

I also tried it with AutoIncrement flag set and multiple reads in one I2CIN statement. No chance.

I Think it might have to do with the address information which the BS sends via I2C because the PCF8591 doesn't need any address.

Any Ideas? Working code?

I'm just thinking: Maybe I should put the controlbyte into the I2CIN address location and drop the I2COUT statements. When the PCF interprets the sent 0 address as a control byte then everything is clear. Will try after work...

Code? I2CIN 8, I2CIdSharpsRead, I2CSharpsControlByte00, [B0]

Thanks

Gerhard

Reply to
Gerhard Schwanz
Loading thread data ...

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.