 |
 |
| View previous topic :: View next topic |
| Author |
Message |
Guest
|
| Re: Problem with I2C and A/D |
Posted: Fri Oct 21, 2005 5:18 am |
|
|
| John Ilicitean wrote: | | The I2c address is 1001 010X according to manual. |
When I look at the TI datasheet for this device, it appears that the I2C address is hardwired into the chip. The available address range is from 1001 000 to 1001 111. A package marking indicate this 3 last bits by ADx.
Are you sure your chip address is really 1001 010 ? |
|
 |
John Ilicitean
Joined: 07 Jul 2005 Posts: 27 Location: Rotova
|
|
Posted: Fri Oct 21, 2005 9:23 am |
|
|
Yes, I'm sure that my device is AD2, because it puts it on the chip.
Anyhow, i have tried all the possible address and it answers none the ADS1100 |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Oct 23, 2005 5:32 pm |
|
|
This article in Circuit Cellar has a routine to read the ADS1100.
http://www.circuitcellar.com/fi2003/abstracts/F164abstract.pdf
They follow the data sheet exactly, and so they don't do a NACK
on the last read.
Here's the routine from that article:
| Quote: |
unsigned int Measure_ADC(void)
{
BYTE temp;
unsigned int Result=0;
I2C_start();
I2C_write(0x91); // ADC address, then read
Result = I2C_read(1); // hi byte
Result = ((Result << 8) + I2C_read(1)); // lo byte
temp = I2C_read(1); // config register,
not used
I2C_stop();
return (Result);
} |
Here is the routine after converting it to CCS, and
adding a demo program. Note that the ADS1100 does
not require initialization in order to use it. It comes
up in "continuous conversion" mode, upon power-up.
You can just start reading it.
| Code: |
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use RS232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#use i2c(Master, sda=PIN_C4, scl=PIN_C3)
#define ADS1100_I2C_WRITE_ADDRESS 0x90
#define ADS1100_I2C_READ_ADDRESS 0x91
int16 read_ADS1100(void)
{
int8 temp;
int16 result=0;
i2c_start();
i2c_write(ADS1100_I2C_READ_ADDRESS);
result = i2c_read(); // Read MSB
result = ((result << 8) + i2c_read()); // Read LSB
// Note: The data sheet shows an ACK on the last
// read, so that's what is done in the line below.
temp = i2c_read(); // Read Config register
// If you want to do a NACK on the last read, which
// is the normal method for i2c, then change the
// line above to this:
// temp = i2c_read(0);
i2c_stop();
return(result); // Return 16-bit A/D result
}
//======================================
main(void)
{
int16 adc_value;
// Read and display the A/D value every 1/2 second.
while(1)
{
adc_value = read_ADS1100();
printf("Value read = %LX \n\r", adc_value);
delay_ms(500);
}
}
|
If you still can't make it work after trying this code,
then I think you have a hardware problem. |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|