From: starfire on
Hi all -

Has anyone had any experience with using multiple I2C devices is a bus
architecture?

I am using a PIC18LF252 uC, a 24LC256 serial EEPROM, and three Dallas DS1803
dual 100K programmable pots in a bus. The circuit is on a printed circuit
board (not wire-wrapped or breadboarded). The total length of SDA and SCL
lines is about 3 inches.

I'm using the CCS C compiler with built-in I2C functions for I2C start,
stop, write, and read. I had to write my own routines to handle the DS1803
device specifics. I breadboarded a single DS1803 with some test code using
the routines to verify correct operation. It seemed to work well. When I
put the three DS1803 chips in the circuit, along with the memory chip
though, it gives erratic results.

I looked at the SDA and SCL on a logic analyzer and found out why it was
erratic. Every other time I executed a read instruction, the SDA line
stayed low (did not output the stop condition). The following command fails
but resets the SDA line high again so the next instruction following works
again. This repeats indefinitely. Every other read works. The write
cycles seem to be OK so I thought it must be timing related. The DS1803
reads both pot values sequentially and I thought the data on the second read
was being output too soon or something. I inserted small delays (about
10ms) between byte reads in the sequence. No help. I added a second stop
after the first stop (thinking at least one would get through). That made
matters worse.

I've varied the size of the pullup resistors from 1.2K to 4.7K. No value
made it work completely, although some values seemed to work a little better
than others (around 2.0K to 2.2K worked the best). One DS1803 and the
memory seem to work almost all the time while the other two DS1803s exhibit
this toggling-read symptom. The daisy-chain for the bus goes from
memory-to-PIC-to-DS1803A-to-DS1803B-to-DS1803C. DS1803B is the one working
most of the time while A and C toggle.

Does anyone have any idea what's happening or what I may not have
considered?

TIA

Dave


From: Wil Taphoorn on
starfire wrote:
>
> Every other time I executed a read instruction, the SDA line stayed low
> (did not output the stop condition).

Looks like the 'low' is the first next data bit output by the slave. Are
you sure you NAK'ed on the last byte read?

--
Wil
From: Paul Carpenter on
On Wednesday, in article
<1117u2aiovrobdc(a)corp.supernews.com>
starfire151(a)cableone.net "starfire" wrote:
>Hi all -
>
>Has anyone had any experience with using multiple I2C devices is a bus
>architecture?

Yes many times.

>I am using a PIC18LF252 uC, a 24LC256 serial EEPROM, and three Dallas DS1803
>dual 100K programmable pots in a bus. The circuit is on a printed circuit
>board (not wire-wrapped or breadboarded). The total length of SDA and SCL
>lines is about 3 inches.

Last time I used DS1803 I had four of them, plus several PCF8574 and PCF8591
off a PCF8584 controller on a H8.

>I'm using the CCS C compiler with built-in I2C functions for I2C start,
>stop, write, and read. I had to write my own routines to handle the DS1803
>device specifics. I breadboarded a single DS1803 with some test code using
>the routines to verify correct operation. It seemed to work well. When I
>put the three DS1803 chips in the circuit, along with the memory chip
>though, it gives erratic results.

The DS1803 is not too difficult to write for. Are you sure you are putting
the correct addresses out for all devices. Single unit has base address
(0x50) however adding extra unit addresses tends to be where most people
screw up on creating I2C addresses.

What sub-addresses (unit numbers) are you using for the DS1803 devices?

>I looked at the SDA and SCL on a logic analyzer and found out why it was
>erratic. Every other time I executed a read instruction, the SDA line
>stayed low (did not output the stop condition). The following command fails
>but resets the SDA line high again so the next instruction following works
>again. This repeats indefinitely. Every other read works. The write
>cycles seem to be OK so I thought it must be timing related. The DS1803
>reads both pot values sequentially and I thought the data on the second read
>was being output too soon or something. I inserted small delays (about
>10ms) between byte reads in the sequence. No help. I added a second stop
>after the first stop (thinking at least one would get through). That made
>matters worse.

The first thing I would check is that your are addressing the devices
correctly as getting the addresses wrong in I2C causes a difference between
read and write mode.

Secondly I would check you are sending the correct command as DS1803
supports three different read/write methods pot 0, pot 1 or both pots
depending on the command sent after the address before reading/writing.

I only ever supported single pot read/write, because that was easier
to implement in the application it was for and made parameter passing
smaller.

>I've varied the size of the pullup resistors from 1.2K to 4.7K. No value
>made it work completely, although some values seemed to work a little better
>than others (around 2.0K to 2.2K worked the best). One DS1803 and the
>memory seem to work almost all the time while the other two DS1803s exhibit
>this toggling-read symptom. The daisy-chain for the bus goes from
>memory-to-PIC-to-DS1803A-to-DS1803B-to-DS1803C. DS1803B is the one working
>most of the time while A and C toggle.

The fact that the ones toggling are two addresses apart makes me more
suspicious of addressing fault. That makes me think your address is not
being shifted the correct number of bits.

>Does anyone have any idea what's happening or what I may not have
>considered?

I would start double checking the addressing and command sent first.

If you want <http://www.gnuh8.org.uk/files.htm> includes an I2C example
that has in it a DS1803 module in C that may help. Don't use the read/write
two pots in one command with that code, it won't work, but single pot
read/write will work. This has worked for 5 years on one product.

--
Paul Carpenter | paul(a)pcserviceselectronics.co.uk
<http://www.pcserviceselectronics.co.uk/> PC Services
<http://www.gnuh8.org.uk/> GNU H8 & mailing list info
<http://www.badweb.org.uk/> For those web sites you hate

From: starfire on
Thanks for the reply, Paul.

The addressing is correct for the three devices. I've checked it several
times. The device addresses that are flaky are the 000 and 001. Address
010 seems to work fairly consistently. I've confirmed the addressing with
the logic analyzer.

I've downloaded the example you referred to from your web page and will
examine it. I haven't had a chance to take a look at it yet. I will
probably get a chance today or tomorrow.

Thanks, again.

Dave

"Paul Carpenter" <paul$@pcserv.demon.co.uk> wrote in message
news:20050217.0937.306771snz(a)pcserv.demon.co.uk...
> On Wednesday, in article
> <1117u2aiovrobdc(a)corp.supernews.com>
> starfire151(a)cableone.net "starfire" wrote:
>>Hi all -
>>
>>Has anyone had any experience with using multiple I2C devices is a bus
>>architecture?
>
> Yes many times.
>
>>I am using a PIC18LF252 uC, a 24LC256 serial EEPROM, and three Dallas
>>DS1803
>>dual 100K programmable pots in a bus. The circuit is on a printed circuit
>>board (not wire-wrapped or breadboarded). The total length of SDA and SCL
>>lines is about 3 inches.
>
> Last time I used DS1803 I had four of them, plus several PCF8574 and
> PCF8591
> off a PCF8584 controller on a H8.
>
>>I'm using the CCS C compiler with built-in I2C functions for I2C start,
>>stop, write, and read. I had to write my own routines to handle the
>>DS1803
>>device specifics. I breadboarded a single DS1803 with some test code
>>using
>>the routines to verify correct operation. It seemed to work well. When I
>>put the three DS1803 chips in the circuit, along with the memory chip
>>though, it gives erratic results.
>
> The DS1803 is not too difficult to write for. Are you sure you are putting
> the correct addresses out for all devices. Single unit has base address
> (0x50) however adding extra unit addresses tends to be where most people
> screw up on creating I2C addresses.
>
> What sub-addresses (unit numbers) are you using for the DS1803 devices?
>
>>I looked at the SDA and SCL on a logic analyzer and found out why it was
>>erratic. Every other time I executed a read instruction, the SDA line
>>stayed low (did not output the stop condition). The following command
>>fails
>>but resets the SDA line high again so the next instruction following works
>>again. This repeats indefinitely. Every other read works. The write
>>cycles seem to be OK so I thought it must be timing related. The DS1803
>>reads both pot values sequentially and I thought the data on the second
>>read
>>was being output too soon or something. I inserted small delays (about
>>10ms) between byte reads in the sequence. No help. I added a second stop
>>after the first stop (thinking at least one would get through). That made
>>matters worse.
>
> The first thing I would check is that your are addressing the devices
> correctly as getting the addresses wrong in I2C causes a difference
> between
> read and write mode.
>
> Secondly I would check you are sending the correct command as DS1803
> supports three different read/write methods pot 0, pot 1 or both pots
> depending on the command sent after the address before reading/writing.
>
> I only ever supported single pot read/write, because that was easier
> to implement in the application it was for and made parameter passing
> smaller.
>
>>I've varied the size of the pullup resistors from 1.2K to 4.7K. No value
>>made it work completely, although some values seemed to work a little
>>better
>>than others (around 2.0K to 2.2K worked the best). One DS1803 and the
>>memory seem to work almost all the time while the other two DS1803s
>>exhibit
>>this toggling-read symptom. The daisy-chain for the bus goes from
>>memory-to-PIC-to-DS1803A-to-DS1803B-to-DS1803C. DS1803B is the one
>>working
>>most of the time while A and C toggle.
>
> The fact that the ones toggling are two addresses apart makes me more
> suspicious of addressing fault. That makes me think your address is not
> being shifted the correct number of bits.
>
>>Does anyone have any idea what's happening or what I may not have
>>considered?
>
> I would start double checking the addressing and command sent first.
>
> If you want <http://www.gnuh8.org.uk/files.htm> includes an I2C example
> that has in it a DS1803 module in C that may help. Don't use the
> read/write
> two pots in one command with that code, it won't work, but single pot
> read/write will work. This has worked for 5 years on one product.
>
> --
> Paul Carpenter | paul(a)pcserviceselectronics.co.uk
> <http://www.pcserviceselectronics.co.uk/> PC Services
> <http://www.gnuh8.org.uk/> GNU H8 & mailing list info
> <http://www.badweb.org.uk/> For those web sites you hate
>


From: starfire on
Thanks for the reply, Wil.

I will double check the logic analyzer output and look for the NAKs, again.

Dave

"Wil Taphoorn" <wil(a)nogo.wtms.nl> wrote in message
news:42145B38.FC0FD276(a)nogo.wtms.nl...
> starfire wrote:
>>
>> Every other time I executed a read instruction, the SDA line stayed low
>> (did not output the stop condition).
>
> Looks like the 'low' is the first next data bit output by the slave. Are
> you sure you NAK'ed on the last byte read?
>
> --
> Wil


 |  Next  |  Last
Pages: 1 2 3 4
Prev: Encryption Algorithm
Next: An OS for the AT91SAM7Sxx??