Problem reading second byte from 16bit ADC "ADS1110"
avionikeren
Posts: 64
I`m unable to read the second byte from the ADS1110, it returns only logic high`s (adc0[1] = 255)
Is there anyone with an idea?
Is there anyone with an idea?
PUB i2cRead | i, i2cWriteData dira[adc1sda] ~~ dira[adc1scl] ~~ outa[adc1sda] := 1 outa[adc1scl] := 1 outa[adc1sda] := 0 outa[adc1scl] := 0 'write i2cWriteData := $91 << 24 repeat 8 outa[adc1sda] := (i2cWriteData <-= 1) & 1 outa[adc1scl] := 1 outa[adc1scl] := 0 dira[adc1sda] ~ outa[adc1scl] := 1 outa[adc1scl] := 0 'read1 i2cData := 0 repeat 8 outa[adc1scl] := 1 i2cData := (i2cData << 1) | ina[adc1sda] outa[adc1scl] := 0 dira[adc1sda] ~~ outa[adc1scl] := 1 outa[adc1sda] := 0 outa[adc1scl] := 0 dira[adc1sda] ~ adc0[0] := i2cData 'read2 i2cData := 0 repeat 8 outa[adc1scl] := 1 i2cData := (i2cData << 1) | ina[adc1sda] outa[adc1scl] := 0 dira[adc1sda] ~~ outa[adc1scl] := 1 outa[adc1sda] := 0 outa[adc1scl] := 0 adc0[1] := i2cData outa[adc1scl] := 1 outa[adc1sda] := 1
spin
3K
Comments
You should anyway not drive the SDA pin High. For that I2C uses a pullup. To output a HIGH you set dira=0 and to output a LOW you set dira to 1 (and the outa bit stays always Low).
Here is a untested changed version of your Read methode: The SCL line is driven High and Low here so you need no pullup on SCL. But SDA needs one.
Andy
The changes you made to the code works perfect.