Well, I tried that code and even after fixing syntax, it does not work.
By the way, I tried to do my own code for that chip, but that also does not work - returns 64 for MSB and LSB bytes. The hardware wiring is correct, because if I remove VDD to chip, these bytes are returned as 0.
Here's my code for it, according to chip datasheet:
1. Write to Config register:
First byte: 0b10010000 (first 7-bit I2C address followed by a low R/W bit)
Second byte: 0b00000001 (points to Config register)
Third byte: 0b10000100 (MSB of the Config register to be written)
Fourth byte: 0b10000011 (LSB of the Config register to be written)
2. Write to Address Pointer register:
First byte: 0b10010000 (first 7-bit I2C address followed by a low R/W bit)
Second byte: 0b00000000 (points to Conversion register)
3. Read Conversion register:
First byte: 0b10010001 (first 7-bit I2C address followed by a high R/W bit)
Second byte: the ADS111x response with the MSB of the Conversion register
Third byte: the ADS111x response with the LSB of the Conversion register
Code:
DO
i2cwrite i2dta, i2clk, $48,$01,[132,131] 'write config
pause 10
i2cwrite i2dta, i2clk, $48,$0 'convert
pause 10
i2cread i2dta, i2clk, $48,[data1,data2] 'read data
serout2 portc.5,90, ["adc=",dec data1, dec data2,13,10]
LOOP
Bookmarks