EmbeddedRelated.com
Forums

rcm2200 & I2C problem

Started by stujo September 27, 2003
I am trying to set up a PCF8591 A/D converter with my RCM2200
rabbit. I altered I2C.LIB to use bits 3 and 4 (this was the only
alteration I did there). I have confirmed that the start and write
routines all happen in correct order by using breakpoints and single
steps. All appears ok but the 8591 doesn't pull the data pin low
after I send the address. Everything I have tried tells me the
software is working so I assume it is a hardware problem. Easiest
thing was to try another 8591, same results. Any help / suggestion
would be great. Below is a pinout of my setup and my main script.

Pin 1 - 4 = analog inputs, each tied high as a place to start
Pin 5 - 7 = device address, tied low for address 90 hex
Pin 8 = Vss = ground
Pin 9 = SDA, tied high w/ 10 K resistor, connected to Port D bit 4
Pin 10= SCL, tied high w/ 10 K resistor, connected to Port D bit 3
Pin 11= OSC, no connection
Pin 12= EXT, tied low
Pin 13= AGND, tied low
Pin 14= Vref, tied low
Pin 15= Analog out, no connection
Pin 16= Vdd = 5 Vdc

---------
#class auto
#use "I2C.LIB"
#define ADC_ADDRESS 0x90 // 1st nibble = 1001 , 2nd = 0000
#define ADC_CONTROL 0x00 // control byte
void main(){
int j,i;
char *ch;
i2c_init(); if(i2c_startw_tx()){ printf("\n\n\nstart if fubar\n");}
else {printf("\n\nstarted ok\n\n");}

//7 bit address with 0 at end for write
if(i2c_write_char(ADC_ADDRESS)){
printf("\n\n\nwrite address is fubar\n ");
}
else {printf("\n\naddressed ok \n\n",ADC_ADDRESS);}

//control word
if(i2c_write_char(ADC_CONTROL)){
printf("\n\n\nwrite control1 is fubar\n ");
}
else { printf("\n\ncontrol 1 ok \n\n",ADC_CONTROL);}

//read data
if(i2c_read_char(ch)){
printf("\n\nread data is fubar\n ");
}
else { printf("\n\nread data ok \n\n",*ch); }

i2c_stop_tx();
printf("\n\nstopped \n\n\n");

----------

I am sure it is a stupid mistake but at this point I will risk
embarassment in order to get this thing going.

Thanks in advance.


1. VREF is the input for voltage reference; it can't be tied to GND, you
have to supply an external stable reference. Just to test you may
connect to Vdd. Read carefully datasheet and see also the examples.
2. Analog voltage inputs may be connected to Vdd only if Vref is also
connected to Vdd. More generally they can be tied to Vref or to GND.
Make tests with GND or Vref is not so good, place a simple 10K trimmer
could be a lot better.
3. In my DC release I2C.LIB realizes a software driven I2C interface, no
modifications are needed for it; of course you could use different pins
and so you could modify a little the library code. You have to write
your PCF8591 driver using those macros and functions respecting all
informations found in the datasheet. Personally I think you have also a
software problem.

stujo wrote:

>I am trying to set up a PCF8591 A/D converter with my RCM2200
>rabbit. I altered I2C.LIB to use bits 3 and 4 (this was the only
>alteration I did there). I have confirmed that the start and write
>routines all happen in correct order by using breakpoints and single
>steps. All appears ok but the 8591 doesn't pull the data pin low
>after I send the address. Everything I have tried tells me the
>software is working so I assume it is a hardware problem. Easiest
>thing was to try another 8591, same results. Any help / suggestion
>would be great. Below is a pinout of my setup and my main script.
>
>Pin 1 - 4 = analog inputs, each tied high as a place to start
>Pin 5 - 7 = device address, tied low for address 90 hex
>Pin 8 = Vss = ground
>Pin 9 = SDA, tied high w/ 10 K resistor, connected to Port D bit 4
>Pin 10= SCL, tied high w/ 10 K resistor, connected to Port D bit 3
>Pin 11= OSC, no connection
>Pin 12= EXT, tied low
>Pin 13= AGND, tied low
>Pin 14= Vref, tied low
>Pin 15= Analog out, no connection
>Pin 16= Vdd = 5 Vdc
>
>---------
>#class auto
>#use "I2C.LIB"
>#define ADC_ADDRESS 0x90 // 1st nibble = 1001 , 2nd = 0000
>#define ADC_CONTROL 0x00 // control byte
>void main(){
> int j,i;
> char *ch;
> i2c_init(); > if(i2c_startw_tx()){ printf("\n\n\nstart if fubar\n");}
> else {printf("\n\nstarted ok\n\n");}
>
> //7 bit address with 0 at end for write
> if(i2c_write_char(ADC_ADDRESS)){
> printf("\n\n\nwrite address is fubar\n ");
> }
> else {printf("\n\naddressed ok \n\n",ADC_ADDRESS);}
>
> //control word
> if(i2c_write_char(ADC_CONTROL)){
> printf("\n\n\nwrite control1 is fubar\n ");
> }
> else { printf("\n\ncontrol 1 ok \n\n",ADC_CONTROL);}
>
> //read data
> if(i2c_read_char(ch)){
> printf("\n\nread data is fubar\n ");
> }
> else { printf("\n\nread data ok \n\n",*ch); }
>
> i2c_stop_tx();
> printf("\n\nstopped \n\n\n");
>
>----------
>
>I am sure it is a stupid mistake but at this point I will risk
>embarassment in order to get this thing going.
>
>Thanks in advance. >
>To unsubscribe from this group, send an email to:
>rabbit-semi-unsubscribe@rabb... >
>">http://docs.yahoo.com/info/terms/