Shop OBEX P1 Docs P2 Docs Learn Events
I2C bus shared with uart? — Parallax Forums

I2C bus shared with uart?

ArchiverArchiver Posts: 46,084
edited 2003-12-23 06:38 in General Discussion
Hi,

I like some thoughts on the following scenario:
I have an I2C bus with several slaves (eg. eeproms) and a SX28 with VP uart.
The I2C start condition is SDA high to low with SCL high.
The I2C stop condition is SDA low to high with SCL high.
I want to use the SCL as the TX towards the SX28. The SDA serves as RX.

Assume I2C bus is idle, so SCL=H (output or input) and SDA=H (input).
I lower SCL for a specified time. This signals the SX28 that uart mode is
entered.
The stamp sends a command string to the SX28 using SCL. No I2C start/stop
conditions occur because SDA remains high. After sending the string, I keep
SCL low and SDA an input. Then the SX28 responds sending data using the
SDA line. Again, no start/stop occurs because now SCL remains low.
The uart mode stays active until the stamp sends a specific terminate command.
This signals the SX28 that I2C mode will be entered and so the SX28 will not
respond
and waits until the SCL stays low again for the specified time.

Could this work? For safety I will put a resistor between the SX28 TX output and
stamp's SDA.

Has anyone ever tried this?

regards peter



[noparse][[/noparse]Non-text portions of this message have been removed]

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-12-22 16:55
    At 05:42 PM 12/22/03 +0100, Peter Verkaik wrote:
    >Hi,
    >
    >I like some thoughts on the following scenario:
    >I have an I2C bus with several slaves (eg. eeproms) and a SX28 with VP uart.
    >The I2C start condition is SDA high to low with SCL high.
    >The I2C stop condition is SDA low to high with SCL high.
    >I want to use the SCL as the TX towards the SX28. The SDA serves as RX.
    >
    >Assume I2C bus is idle, so SCL=H (output or input) and SDA=H (input).
    >I lower SCL for a specified time. This signals the SX28 that uart mode is
    entered.
    >The stamp sends a command string to the SX28 using SCL. No I2C start/stop
    >conditions occur because SDA remains high. After sending the string, I keep
    >SCL low and SDA an input. Then the SX28 responds sending data using the
    >SDA line. Again, no start/stop occurs because now SCL remains low.
    >The uart mode stays active until the stamp sends a specific terminate command.
    >This signals the SX28 that I2C mode will be entered and so the SX28 will not
    respond
    >and waits until the SCL stays low again for the specified time.
    >
    >Could this work? For safety I will put a resistor between the SX28 TX output
    and stamp's SDA.
    >
    >Has anyone ever tried this?
    >
    >regards peter

    Peter -

    Your description is almost too detailed in explaining what you want to do.

    Are you trying to use the same set of physical wires to run synchronous and
    asynchronous serial data (SERIN/SEROUT and SHIFTIN/SHIFTOUT) ? If so, why bother

    when SHIFTIN and SHIFTOUT (or bit banging on some Stamp models) and/or I2CIN and

    I2COUT are available to you ?

    Regards,

    Bruce Bates



    >
    >
    >
    >[noparse][[/noparse]Non-text portions of this message have been removed]
    >
    >
    >To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    >from the same email address that you subscribed. Text in the Subject and Body
    of the message will be ignored.
    >
    >
    >Yahoo! Groups Links
    >
    >To visit your group on the web, go to:
    > http://groups.yahoo.com/group/basicstamps/
    >
    >To unsubscribe from this group, send an email to:
    > basicstamps-unsubscribe@yahoogroups.com
    >
    >Your use of Yahoo! Groups is subject to:
    > http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2003-12-22 19:55
    I don't have two free pins for communication between an SX28 and a basic
    stamp. There is
    however an existing I2C bus. So I have two options:

    1. Program the SX28 as an I2C slave. I have done that before but never got
    the SX28 to recognize an I2C start condition
    when using the stamp's built-in I2C commands. The SX28 always detected a 11
    to 00 transution for SCL and SDA,
    sampling at 4.3 uS. The I2C specs specify a 4.7 uS hold time for the start
    condition, so it should have been detected.
    I guess the stamp lowers SCL faster than 4.3 uS after SDA drops. If I use
    software programmed I2C there is no
    problem but this gives too much overhead and loss of speed.

    2. Program the SX28 with a uart and use the I2C pins when the I2C bus is
    idle.
    I don't need the SX28 to access the eeproms on the I2C bus. I just need to
    communicate
    with the basic stamp. I know I2C can be shared with SPI, but how about a
    uart?
    The uart would follow a strict protocol, something like I described, with
    the stamp always in control.

    regards peter

    Original Message
    From: "Bruce Bates" <bvbates@u...>
    To: <basicstamps@yahoogroups.com>
    Sent: Monday, December 22, 2003 5:55 PM
    Subject: Re: [noparse][[/noparse]basicstamps] I2C bus shared with uart?


    > At 05:42 PM 12/22/03 +0100, Peter Verkaik wrote:
    > >Hi,
    > >
    > >I like some thoughts on the following scenario:
    > >I have an I2C bus with several slaves (eg. eeproms) and a SX28 with VP
    uart.
    > >The I2C start condition is SDA high to low with SCL high.
    > >The I2C stop condition is SDA low to high with SCL high.
    > >I want to use the SCL as the TX towards the SX28. The SDA serves as RX.
    > >
    > >Assume I2C bus is idle, so SCL=H (output or input) and SDA=H (input).
    > >I lower SCL for a specified time. This signals the SX28 that uart mode is
    entered.
    > >The stamp sends a command string to the SX28 using SCL. No I2C start/stop
    > >conditions occur because SDA remains high. After sending the string, I
    keep
    > >SCL low and SDA an input. Then the SX28 responds sending data using the
    > >SDA line. Again, no start/stop occurs because now SCL remains low.
    > >The uart mode stays active until the stamp sends a specific terminate
    command.
    > >This signals the SX28 that I2C mode will be entered and so the SX28 will
    not respond
    > >and waits until the SCL stays low again for the specified time.
    > >
    > >Could this work? For safety I will put a resistor between the SX28 TX
    output and stamp's SDA.
    > >
    > >Has anyone ever tried this?
    > >
    > >regards peter
    >
    > Peter -
    >
    > Your description is almost too detailed in explaining what you want to do.
    >
    > Are you trying to use the same set of physical wires to run synchronous
    and asynchronous serial data (SERIN/SEROUT and SHIFTIN/SHIFTOUT) ? If so,
    why bother
    > when SHIFTIN and SHIFTOUT (or bit banging on some Stamp models) and/or
    I2CIN and
    > I2COUT are available to you ?
    >
    > Regards,
    >
    > Bruce Bates
    >
    >
    >
    > >
    > >
    > >
    > >[noparse][[/noparse]Non-text portions of this message have been removed]
    > >
    > >
    > >To UNSUBSCRIBE, just send mail to:
    > > basicstamps-unsubscribe@yahoogroups.com
    > >from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    > >
    > >
    > >Yahoo! Groups Links
    > >
    > >To visit your group on the web, go to:
    > > http://groups.yahoo.com/group/basicstamps/
    > >
    > >To unsubscribe from this group, send an email to:
    > > basicstamps-unsubscribe@yahoogroups.com
    > >
    > >Your use of Yahoo! Groups is subject to:
    > > http://docs.yahoo.com/info/terms/
    >
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    >
    >
    > Yahoo! Groups Links
    >
    > To visit your group on the web, go to:
    > http://groups.yahoo.com/group/basicstamps/
    >
    > To unsubscribe from this group, send an email to:
    > basicstamps-unsubscribe@yahoogroups.com
    >
    > Your use of Yahoo! Groups is subject to:
    > http://docs.yahoo.com/info/terms/
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2003-12-22 22:55
    >I don't have two free pins for communication between an SX28 and a basic
    >stamp. There is
    >however an existing I2C bus. So I have two options:
    >
    >1. Program the SX28 as an I2C slave. I have done that before but never got
    >the SX28 to recognize an I2C start condition
    >when using the stamp's built-in I2C commands. The SX28 always detected a 11
    >to 00 transution for SCL and SDA,
    >sampling at 4.3 uS. The I2C specs specify a 4.7 uS hold time for the start
    >condition, so it should have been detected.
    >I guess the stamp lowers SCL faster than 4.3 uS after SDA drops. If I use
    >software programmed I2C there is no
    >problem but this gives too much overhead and loss of speed.

    Hi Peter. Look at a 'scope in more detail at what is going on. The
    Stamp does the following when it hits an I2C command, either IN or
    OUT: It pulls both SDA and SCL low simultaneously, as you observed.
    Then about 15 microseconds later, SCL goes back high, then SDA goes
    high (stop condition) then SDA goes low (start condition), then SCL
    goes back low. That whole stop/start transaction takes about 30
    microseconds, so your SX28 should be able to pick it up. The
    shortest edge-edge transition is about 5 microseconds. After the
    start condition, the clocking continues, with acknowledges etc etc..

    What that means for the Stamp programmer is that we don't have to
    worry to much about the condition of the I2C device when the program
    hits the I2C commands, because the command internally assures that
    the device is in a STOP state before it issues the START. We don't
    have to manipulate the pins externally at power up for example, to
    guarantee a STOP condition.

    >2. Program the SX28 with a uart and use the I2C pins when the I2C bus is
    >idle.
    >I don't need the SX28 to access the eeproms on the I2C bus. I just need to
    >communicate
    >with the basic stamp. I know I2C can be shared with SPI, but how about a
    >uart?
    >The uart would follow a strict protocol, something like I described, with
    >the stamp always in control.

    I see no reason why your multiplexing scheme would not work. I have
    done something like that in a system that shared the SCL line for an
    I2C buss with the SCK line for an SPI buss. It was always a
    headache, as the SPI buss expects the clock to be low to start and
    the I2C buss expects the clock to be high to start. (Realizing that
    the Stamp I2C commands always generate an STOP internally prior to
    START took away some of the problem).

    In general IMHO it is a lot less confusing to keep the busses
    separate, and the same thing would apply to the RS232 scheme, as you
    will _always_ have to take care for the proper sequence of pins. But
    if you are short of pins, what else can you do?

    -- regards,
    Tracy


    >
    >regards peter
    >
    >
    Original Message
    >From: "Bruce Bates" <bvbates@u...>
    >To: <basicstamps@yahoogroups.com>
    >Sent: Monday, December 22, 2003 5:55 PM
    >Subject: Re: [noparse][[/noparse]basicstamps] I2C bus shared with uart?
    >
    >
    >> At 05:42 PM 12/22/03 +0100, Peter Verkaik wrote:
    >> >Hi,
    >> >
    >> >I like some thoughts on the following scenario:
    >> >I have an I2C bus with several slaves (eg. eeproms) and a SX28 with VP
    >uart.
    >> >The I2C start condition is SDA high to low with SCL high.
    >> >The I2C stop condition is SDA low to high with SCL high.
    >> >I want to use the SCL as the TX towards the SX28. The SDA serves as RX.
    >> >
    >> >Assume I2C bus is idle, so SCL=H (output or input) and SDA=H (input).
    >> >I lower SCL for a specified time. This signals the SX28 that uart mode is
    >entered.
    >> >The stamp sends a command string to the SX28 using SCL. No I2C start/stop
    >> >conditions occur because SDA remains high. After sending the string, I
    >keep
    >> >SCL low and SDA an input. Then the SX28 responds sending data using the
    >> >SDA line. Again, no start/stop occurs because now SCL remains low.
    >> >The uart mode stays active until the stamp sends a specific terminate
    >command.
    >> >This signals the SX28 that I2C mode will be entered and so the SX28 will
    >not respond
    >> >and waits until the SCL stays low again for the specified time.
    > > >
    >> >Could this work? For safety I will put a resistor between the SX28 TX
    >output and stamp's SDA.
    >> >
    >> >Has anyone ever tried this?
    >> >
    >> >regards peter
    >>
    >> Peter -
    >>
    >> Your description is almost too detailed in explaining what you want to do.
    >>
    >> Are you trying to use the same set of physical wires to run synchronous
    >and asynchronous serial data (SERIN/SEROUT and SHIFTIN/SHIFTOUT) ? If so,
    >why bother
    >> when SHIFTIN and SHIFTOUT (or bit banging on some Stamp models) and/or
    >I2CIN and
    >> I2COUT are available to you ?
    >>
    >> Regards,
    >>
    >> Bruce Bates
    >>
    >>
    >>
    >> >
    >> >
    >> >
    >> >[noparse][[/noparse]Non-text portions of this message have been removed]
    >> >
    >> >
    >> >To UNSUBSCRIBE, just send mail to:
    >> > basicstamps-unsubscribe@yahoogroups.com
    >> >from the same email address that you subscribed. Text in the Subject and
    >Body of the message will be ignored.
    >> >
    >> >
    >> >Yahoo! Groups Links
    >> >
    >> >To visit your group on the web, go to:
    >> > http://groups.yahoo.com/group/basicstamps/
    >> >
    >> >To unsubscribe from this group, send an email to:
    >> > basicstamps-unsubscribe@yahoogroups.com
    >> >
    >> >Your use of Yahoo! Groups is subject to:
    >> > http://docs.yahoo.com/info/terms/
    >>
    >>
    >>
    >> To UNSUBSCRIBE, just send mail to:
    >> basicstamps-unsubscribe@yahoogroups.com
    >> from the same email address that you subscribed. Text in the Subject and
    >Body of the message will be ignored.
    >>
    >>
    >> Yahoo! Groups Links
    >>
    >> To visit your group on the web, go to:
    >> http://groups.yahoo.com/group/basicstamps/
    >>
    >> To unsubscribe from this group, send an email to:
    >> basicstamps-unsubscribe@yahoogroups.com
    >>
    >> Your use of Yahoo! Groups is subject to:
    >> http://docs.yahoo.com/info/terms/
    >>
    >>
    >
    >
    >To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    >from the same email address that you subscribed. Text in the
    >Subject and Body of the message will be ignored.
    >
    >
    >Yahoo! Groups Links
    >
    >To visit your group on the web, go to:
    > http://groups.yahoo.com/group/basicstamps/
    >
    >To unsubscribe from this group, send an email to:
    > basicstamps-unsubscribe@yahoogroups.com
    >
    >Your use of Yahoo! Groups is subject to:
    > http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2003-12-23 01:33
    From: "Tracy Allen" <tracy@e...>
    > [noparse][[/noparse]...]
    > In general IMHO it is a lot less confusing to keep the
    > busses separate, and the same thing would apply to
    > the RS232 scheme, as you will _always_ have to take
    > care for the proper sequence of pins. But if you are
    > short of pins, what else can you do?
    >
    Use an analog multiplexer so you don't have to worry about the signal states
    conflicting?

    Gary
  • ArchiverArchiver Posts: 46,084
    edited 2003-12-23 06:38
    Thanks Tracy.
    I will try to anticipate the stop/start sequence in my
    I2C slave code.

    regards peter

    Original Message
    From: "Tracy Allen" <tracy@e...>
    To: <basicstamps@yahoogroups.com>
    Sent: Monday, December 22, 2003 11:55 PM
    Subject: Re: [noparse][[/noparse]basicstamps] I2C bus shared with uart?


    > >I don't have two free pins for communication between an SX28 and a basic
    > >stamp. There is
    > >however an existing I2C bus. So I have two options:
    > >
    > >1. Program the SX28 as an I2C slave. I have done that before but never
    got
    > >the SX28 to recognize an I2C start condition
    > >when using the stamp's built-in I2C commands. The SX28 always detected a
    11
    > >to 00 transution for SCL and SDA,
    > >sampling at 4.3 uS. The I2C specs specify a 4.7 uS hold time for the
    start
    > >condition, so it should have been detected.
    > >I guess the stamp lowers SCL faster than 4.3 uS after SDA drops. If I use
    > >software programmed I2C there is no
    > >problem but this gives too much overhead and loss of speed.
    >
    > Hi Peter. Look at a 'scope in more detail at what is going on. The
    > Stamp does the following when it hits an I2C command, either IN or
    > OUT: It pulls both SDA and SCL low simultaneously, as you observed.
    > Then about 15 microseconds later, SCL goes back high, then SDA goes
    > high (stop condition) then SDA goes low (start condition), then SCL
    > goes back low. That whole stop/start transaction takes about 30
    > microseconds, so your SX28 should be able to pick it up. The
    > shortest edge-edge transition is about 5 microseconds. After the
    > start condition, the clocking continues, with acknowledges etc etc..
    >
    > What that means for the Stamp programmer is that we don't have to
    > worry to much about the condition of the I2C device when the program
    > hits the I2C commands, because the command internally assures that
    > the device is in a STOP state before it issues the START. We don't
    > have to manipulate the pins externally at power up for example, to
    > guarantee a STOP condition.
    >
    > >2. Program the SX28 with a uart and use the I2C pins when the I2C bus is
    > >idle.
    > >I don't need the SX28 to access the eeproms on the I2C bus. I just need
    to
    > >communicate
    > >with the basic stamp. I know I2C can be shared with SPI, but how about a
    > >uart?
    > >The uart would follow a strict protocol, something like I described, with
    > >the stamp always in control.
    >
    > I see no reason why your multiplexing scheme would not work. I have
    > done something like that in a system that shared the SCL line for an
    > I2C buss with the SCK line for an SPI buss. It was always a
    > headache, as the SPI buss expects the clock to be low to start and
    > the I2C buss expects the clock to be high to start. (Realizing that
    > the Stamp I2C commands always generate an STOP internally prior to
    > START took away some of the problem).
    >
    > In general IMHO it is a lot less confusing to keep the busses
    > separate, and the same thing would apply to the RS232 scheme, as you
    > will _always_ have to take care for the proper sequence of pins. But
    > if you are short of pins, what else can you do?
    >
    > -- regards,
    > Tracy
    >
    >
    > >
    > >regards peter
    > >
    > >
    Original Message
    > >From: "Bruce Bates" <bvbates@u...>
    > >To: <basicstamps@yahoogroups.com>
    > >Sent: Monday, December 22, 2003 5:55 PM
    > >Subject: Re: [noparse][[/noparse]basicstamps] I2C bus shared with uart?
    > >
    > >
    > >> At 05:42 PM 12/22/03 +0100, Peter Verkaik wrote:
    > >> >Hi,
    > >> >
    > >> >I like some thoughts on the following scenario:
    > >> >I have an I2C bus with several slaves (eg. eeproms) and a SX28 with VP
    > >uart.
    > >> >The I2C start condition is SDA high to low with SCL high.
    > >> >The I2C stop condition is SDA low to high with SCL high.
    > >> >I want to use the SCL as the TX towards the SX28. The SDA serves as
    RX.
    > >> >
    > >> >Assume I2C bus is idle, so SCL=H (output or input) and SDA=H (input).
    > >> >I lower SCL for a specified time. This signals the SX28 that uart mode
    is
    > >entered.
    > >> >The stamp sends a command string to the SX28 using SCL. No I2C
    start/stop
    > >> >conditions occur because SDA remains high. After sending the string, I
    > >keep
    > >> >SCL low and SDA an input. Then the SX28 responds sending data using
    the
    > >> >SDA line. Again, no start/stop occurs because now SCL remains low.
    > >> >The uart mode stays active until the stamp sends a specific terminate
    > >command.
    > >> >This signals the SX28 that I2C mode will be entered and so the SX28
    will
    > >not respond
    > >> >and waits until the SCL stays low again for the specified time.
    > > > >
    > >> >Could this work? For safety I will put a resistor between the SX28 TX
    > >output and stamp's SDA.
    > >> >
    > >> >Has anyone ever tried this?
    > >> >
    > >> >regards peter
    > >>
    > >> Peter -
    > >>
    > >> Your description is almost too detailed in explaining what you want to
    do.
    > >>
    > >> Are you trying to use the same set of physical wires to run synchronous
    > >and asynchronous serial data (SERIN/SEROUT and SHIFTIN/SHIFTOUT) ? If so,
    > >why bother
    > >> when SHIFTIN and SHIFTOUT (or bit banging on some Stamp models) and/or
    > >I2CIN and
    > >> I2COUT are available to you ?
    > >>
    > >> Regards,
    > >>
    > >> Bruce Bates
    > >>
    > >>
    > >>
    > >> >
    > >> >
    > >> >
    > >> >[noparse][[/noparse]Non-text portions of this message have been removed]
    > >> >
    > >> >
    > >> >To UNSUBSCRIBE, just send mail to:
    > >> > basicstamps-unsubscribe@yahoogroups.com
    > >> >from the same email address that you subscribed. Text in the Subject
    and
    > >Body of the message will be ignored.
    > >> >
    > >> >
    > >> >Yahoo! Groups Links
    > >> >
    > >> >To visit your group on the web, go to:
    > >> > http://groups.yahoo.com/group/basicstamps/
    > >> >
    > >> >To unsubscribe from this group, send an email to:
    > >> > basicstamps-unsubscribe@yahoogroups.com
    > >> >
    > >> >Your use of Yahoo! Groups is subject to:
    > >> > http://docs.yahoo.com/info/terms/
    > >>
    > >>
    > >>
    > >> To UNSUBSCRIBE, just send mail to:
    > >> basicstamps-unsubscribe@yahoogroups.com
    > >> from the same email address that you subscribed. Text in the Subject
    and
    > >Body of the message will be ignored.
    > >>
    > >>
    > >> Yahoo! Groups Links
    > >>
    > >> To visit your group on the web, go to:
    > >> http://groups.yahoo.com/group/basicstamps/
    > >>
    > >> To unsubscribe from this group, send an email to:
    > >> basicstamps-unsubscribe@yahoogroups.com
    > >>
    > >> Your use of Yahoo! Groups is subject to:
    > >> http://docs.yahoo.com/info/terms/
    > >>
    > >>
    > >
    > >
    > >To UNSUBSCRIBE, just send mail to:
    > > basicstamps-unsubscribe@yahoogroups.com
    > >from the same email address that you subscribed. Text in the
    > >Subject and Body of the message will be ignored.
    > >
    > >
    > >Yahoo! Groups Links
    > >
    > >To visit your group on the web, go to:
    > > http://groups.yahoo.com/group/basicstamps/
    > >
    > >To unsubscribe from this group, send an email to:
    > > basicstamps-unsubscribe@yahoogroups.com
    > >
    > >Your use of Yahoo! Groups is subject to:
    > > http://docs.yahoo.com/info/terms/
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    >
    >
    > Yahoo! Groups Links
    >
    > To visit your group on the web, go to:
    > http://groups.yahoo.com/group/basicstamps/
    >
    > To unsubscribe from this group, send an email to:
    > basicstamps-unsubscribe@yahoogroups.com
    >
    > Your use of Yahoo! Groups is subject to:
    > http://docs.yahoo.com/info/terms/
    >
    >
Sign In or Register to comment.