ADS7828 i2c ADC
Jonathan
Posts: 1,023
Hi All,
I'm trying to use a ADS7828 with the prop. Trouble is that I am using a breakout board for it (it's a TSSOP package) and so I can't be %100 sure that I have it mounted OK. So, I'm hoping someone can look at this code and tell me if it ought to be working or not. The ADC is set to address $A0, meaning both address pins are tied to ground. I have a 4.7k pullup on both SDA and CLK. I am using the basic i2c object, clk is set to pin 6 and sda to one higher, 7.
Any help would be much appreciated. I want to use this part so that I can use the eeprom i2c lines to save pins. All I get now for the adcResult is 65535.
Thanks!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
I'm trying to use a ADS7828 with the prop. Trouble is that I am using a breakout board for it (it's a TSSOP package) and so I can't be %100 sure that I have it mounted OK. So, I'm hoping someone can look at this code and tell me if it ought to be working or not. The ADC is set to address $A0, meaning both address pins are tied to ground. I have a 4.7k pullup on both SDA and CLK. I am using the basic i2c object, clk is set to pin 6 and sda to one higher, 7.
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 ' PropTerm #0, WHITE,CYAN,RED,PINK,BLUE,GREEN,YELLOW,GRAY ' ADC adcClock = 6 ' adcData = 7 adcAddr = $A0 VAR word adcResult OBJ term : "PC_Interface" adc : "Basic_I2C_Driver" PUB init term.start(31,30) term.str(string("House Controller 0.0.1")) wait_ms(1000) repeat term.out(0) adc.initialize(adcClock) adc.start(adcClock) 'adc.write(adcClock,adcAddr) adc.write(adcClock,%1001_0001) adc.write(adcClock,%1111_1111) adcResult.byte[noparse][[/noparse]0] := adc.read(adcClock,adcAddr) adcResult.byte[noparse][[/noparse]1] := adc.read(adcClock,adcAddr) term.str(string("ADC result: ")) term.dec(adcresult) wait_ms(500)
Any help would be much appreciated. I want to use this part so that I can use the eeprom i2c lines to save pins. All I get now for the adcResult is 65535.
Thanks!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
Comments
Look at the datasheets for the ADC. You'll find that all write transfers begin with a start transition (using adc.start) followed by a device select code (adc.write) followed by a command byte (adc.write) followed by a stop transition (adc.stop). All read transfers begin with a start transition, a device select code (adc.write) that indicates this is a read operation, followed by reads (adc.read) and a final stop transition. The reads have to have an acknowledge bit set true except for the last byte where it is false. Look at the examples in James' device objects.
Thanks for the help. I'll go get the object you reccomend. I'll also go get the datasheets for the devices James uses in the object. Hopefully I'm on the road to success!
Thanks again, I really appreciate the help!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
Thanks for the help. I finally got it to work. I had a variety of both harware and software issued. James's devicepresent routine got me on the right path. I'll be making a little object for this device for the OBEX.
Thanks again!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot