Hi,
did you see datasheet
Write to Config register:
First byte: 0b10010000 (first 7-bit I2C address followed by a low read/write bit) (H90/H91 OK)
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)
Write to Pointer register:
First byte: 0b10010000 (first 7-bit I2C address followed by a low read/write bit) (H90/H91 OK)
Second byte: 0b00000000 (points to Conversion register)
Read Conversion register:
First byte: 0b10010001 (first 7-bit I2C address followed by a high read/write bit)
Second byte: the ADS1113/4/5 response with the [b:fe75ea821a]MSB[/b:fe75ea821a] of the Conversion register
Third byte: the ADS1113/4/5 response with the [b:fe75ea821a]LSB[/b:fe75ea821a] of the Conversion register
Try code:
[code:1:fe75ea821a]Config Portd.0 = Output
Dim Hibyte As Byte
Dim Lobyte As Byte
Dim W_addr As Byte
Dim R_addr As Byte
'addr_pin grounded
'address for write to ads1115
W_addr = &H90
'address for read from ads1115
R_addr = &H91
' Configure pins to to use for the I²C bus
Config Scl = Portc.0 'Is serial clock SCL
Config Sda = Portc.2 'Is serial data SDA
I2cinit
'Const Config_high = &B11000000 '6144
'Const Config_high = &B11000010 '4096
Const Config_high = &B11000100 '2048
'Const Config_high = &B11000110 '1024
Const Config_low = &B00000000
I2cstart
I2cwbyte W_addr
I2cwbyte &B00000001
I2cwbyte Config_high
I2cwbyte Config_low
I2cstop
Waitms 25
'******************************************
Do
Gosub Read_ad
Cls
Lcd Hibyte
Lowerline
Lcd Lobyte
Wait 1
Loop
End
Read_ad:
I2cstart ' Generate start code
I2cwbyte W_addr ' send address
I2cwbyte 0
I2cstart ' start condition
I2cwbyte R_addr ' slave address
I2crbyte Lobyte , Ack
I2crbyte Hibyte , Nack
I2cstop
Return[/code:1:fe75ea821a]
↧