Electrosolve
- 7th August 2009, 22:17
I am having problems reading a ADC121C021 12 bit ADC with PBP.
From the data sheet it appears that the slave address is 54h and the conversion result register is 0h.
However, when I use the code below I get a read error.
I have written a routine to cycle addresses from 0 to 255 to see if I could find a slave address that does work.
I have found that a slave address of $A8 does return a result but whilst the result for an input of 0 to 5 volts produces an output of 0 to 4096, there seems to be gaps of 8 in the result i.e. 356,364,380 etc.
I'm not sure what is going on.
Any thoughts?
i2cclock var portb.2
i2cdata var portb.1
slave_address var byte
data_read var word
adc_register var byte
slave_address=$54
adc_register=0
I2Cread i2cdata,i2cclock,slave_address,adc_register,[data_read],error
hserout [#data_read,13,10]
program continues --
error:
hserout ["Read error",13,10]
From the data sheet it appears that the slave address is 54h and the conversion result register is 0h.
However, when I use the code below I get a read error.
I have written a routine to cycle addresses from 0 to 255 to see if I could find a slave address that does work.
I have found that a slave address of $A8 does return a result but whilst the result for an input of 0 to 5 volts produces an output of 0 to 4096, there seems to be gaps of 8 in the result i.e. 356,364,380 etc.
I'm not sure what is going on.
Any thoughts?
i2cclock var portb.2
i2cdata var portb.1
slave_address var byte
data_read var word
adc_register var byte
slave_address=$54
adc_register=0
I2Cread i2cdata,i2cclock,slave_address,adc_register,[data_read],error
hserout [#data_read,13,10]
program continues --
error:
hserout ["Read error",13,10]