EmbeddedRelated.com
Forums
Memfault Beyond the Launch

i2c repeater

Started by Nadav October 12, 2004
Hi,

I wanted to implement an i2c repeater in software. Actually, Not a
complete i2c but only one master to one slave repeater. I thought I
can use a microcontroller and connect two I/Os to the master and 2
more to the slave in open drain fasion. So I need to reflect the clock
from the master to the slave and the data to/from the master from/to
the slave, depending on the direction. I thought I would use some kind
of buffering (1 bit or 8 bit).

Does anyone did somthing like that? Is it possible? What tricks to
use?
I know of few problems in the way, such as:
1) If I'll use one bit buffer the master will wait for Akn after the
8th bit while the slave only got the 7th.
2) If I'll use 8 bit buffer, what to do when the last byte of a
transaction was corrupted?
3) What is the best way to handle slatting?

Thank a lot for any help.
Nadav.
> Hi, > > I wanted to implement an i2c repeater in software. Actually, Not a > complete i2c but only one master to one slave repeater. I thought I > can use a microcontroller and connect two I/Os to the master and 2 > more to the slave in open drain fasion. So I need to reflect the clock > from the master to the slave and the data to/from the master from/to > the slave, depending on the direction. I thought I would use some kind > of buffering (1 bit or 8 bit). > > Does anyone did somthing like that? Is it possible? What tricks to > use? > I know of few problems in the way, such as: > 1) If I'll use one bit buffer the master will wait for Akn after the > 8th bit while the slave only got the 7th. > 2) If I'll use 8 bit buffer, what to do when the last byte of a > transaction was corrupted? > 3) What is the best way to handle slatting? > > Thank a lot for any help. > Nadav.
I've done this and planning on making it public on my website soon. The limitations are: - No clock-stretching from the slave-side is allowed (clock is allways driven by the master) - Masters can only be on the 'master' side. (Slaves can be on either side.) - Speed: I could get it up to about 50kHz clock rate on an AVR. Might get higher if you optimize code by hand. You don't have to actually understand the protocol and know when to drive which way: you can write code that monitors both the master and the slave side data lines and reflects the correct values back and forth. That way there's no buffering needed. Regards, Andras Tantos
Parden my ignorance, but why is a microcontroller needed for an I2C repeater?
Can't you just split the signal in two with added drivers so the signal isn't
degraded?

"DaveC" <bobason456@hotmail.com> wrote in message
news:Xns9581E26DC1989ohirohotmailcom@203.96.16.33...
> garykato@aol.com (Gary Kato) wrote in > news:20041013013647.04811.00004572@mb-m24.aol.com: > > > Parden my ignorance, but why is a microcontroller needed for an I2C > > repeater? Can't you just split the signal in two with added drivers so > > the signal isn't degraded? > > > > > > I'd say not, because I2C has one bidirectional data line, the protocol > defines what side is to drive the line while the other listens. Not > somthing that would be easy to do with normal line drivers. > > At any rate, 6 pin MCU's would be cheaper and smaller.
Why not use a Philips PCA9515A, a I2C bus repeater in a SO-8 package. Only $0.70.... Meindert
"DaveC" <bobason456@hotmail.com> wrote in message

> I'd say not, because I2C has one bidirectional data line, the protocol > defines what side is to drive the line while the other listens. Not > somthing that would be easy to do with normal line drivers.
It's easy to do with a few FETs. Philips has an application note about it somewhere: the data (and clock) line is a float-up-pull-down, so by using the intrinsic diode across the Drain/Source, one "side" can pull down the other; and by using normal FET behavior, the other side can pull down the one. The same circuit can be used for voltage-level mapping (like 3v to 5v) and isolation (for low power) From memory (which is probably wrong), you (I think) ground the Gate of one N-Channel FET (Enhancement, MOS) and have one side of the SDA/SCL line pull the other one "down" through the FET's intrinsic diode. The other side pulls the one side down by pulling the source down, thus making Vgs sufficiently high for Ids to flow. You have a pullup on each segment and each pullup can pull to a different Vcc. Richard [in PE12]
garykato@aol.com (Gary Kato) wrote in
news:20041013013647.04811.00004572@mb-m24.aol.com: 

> Parden my ignorance, but why is a microcontroller needed for an I2C > repeater? Can't you just split the signal in two with added drivers so > the signal isn't degraded? > >
I'd say not, because I2C has one bidirectional data line, the protocol defines what side is to drive the line while the other listens. Not somthing that would be easy to do with normal line drivers. At any rate, 6 pin MCU's would be cheaper and smaller. DaveC
>> > Parden my ignorance, but why is a microcontroller needed for an I2C >> > repeater? Can't you just split the signal in two with added drivers so >> > the signal isn't degraded? >> > >> > >> >> I'd say not, because I2C has one bidirectional data line, the protocol >> defines what side is to drive the line while the other listens. Not >> somthing that would be easy to do with normal line drivers. >> >> At any rate, 6 pin MCU's would be cheaper and smaller. > > Why not use a Philips PCA9515A, a I2C bus repeater in a SO-8 package. Only > $0.70.... > > Meindert > >
Well, in my case, I also wanted traffic control. Basically make subnets of I2C devices with the same physical address individually addressable from the master side. I also wanted to do it with as small PCB realestate as possible. The phillips device could be nice if you don't need that additional functionality and I indeed thought about that but I couldn't find a distributor who sells small quantities (well I might not have searched hard enough). I went for an 8-pin AVR MCU. Regards, Andras Tantos
"Andras Tantos" <andras_tantos@yahoo.com> wrote in message news:<2t38baF1ounguU1@uni-berlin.de>...
> > Hi, > > > > I wanted to implement an i2c repeater in software. Actually, Not a > > complete i2c but only one master to one slave repeater. I thought I > > can use a microcontroller and connect two I/Os to the master and 2 > > more to the slave in open drain fasion. So I need to reflect the clock > > from the master to the slave and the data to/from the master from/to > > the slave, depending on the direction. I thought I would use some kind > > of buffering (1 bit or 8 bit). > > > > Does anyone did somthing like that? Is it possible? What tricks to > > use? > > I know of few problems in the way, such as: > > 1) If I'll use one bit buffer the master will wait for Akn after the > > 8th bit while the slave only got the 7th. > > 2) If I'll use 8 bit buffer, what to do when the last byte of a > > transaction was corrupted? > > 3) What is the best way to handle slatting? > > > > Thank a lot for any help. > > Nadav. > > I've done this and planning on making it public on my website soon. The > limitations are: > - No clock-stretching from the slave-side is allowed (clock is allways > driven by the master) > - Masters can only be on the 'master' side. (Slaves can be on either side.) > - Speed: I could get it up to about 50kHz clock rate on an AVR. Might get > higher if you optimize code by hand. > > You don't have to actually understand the protocol and know when to drive > which way: you can write code that monitors both the master and the slave > side data lines and reflects the correct values back and forth. That way > there's no buffering needed. > > Regards, > Andras Tantos
Andras, If I want to support clock-stretching from the slave-side what will be the way? If I want to go as high as 400kHz then what? Its of course depends on the micro. speed so what speed should I use? Thanks, Nadav.
"Andras Tantos" <andras_tantos@yahoo.com> wrote in message
news:2t5ma6F1qrbdaU1@uni-berlin.de...
> > Why not use a Philips PCA9515A, a I2C bus repeater in a SO-8 package.
Only
> > $0.70.... > > > > Meindert > > > > > > Well, in my case, I also wanted traffic control. Basically make subnets of > I2C devices with the same physical address individually addressable from
the
> master side.
To do this, I suppose you supply a signal to the repeater to pass or to isolate. The PCA9515A has a control input to accomplish this. Meindert
>If I want to support clock-stretching from the slave-side what will be >the way? >If I want to go as high as 400kHz then what? Its of course depends on >the micro. speed so what speed should I use?
The issue of clock stretching on the SCL line is in hardware the same as the ACK-bit processing on the SDA line. Of course, that's different if you look onto the protocol. For 400kHz use a really fast micro! Such as Scenix. Maybe the better way is to use a CPLD or FPGA and do it in hardware. regards - Henry -- <Schau auch mal auf meine Homepage www.ehydra.dyndns.info> <u.a. Versand von Wasserflohzuchtansatz, Wasserpflanzen/-schnecken, brasilianischer Sauerklee, Natron zum Backen/Baden, u.a.> <Alternativ &#4294967295;ber http://people.freenet.de/algenkocher>

Memfault Beyond the Launch