Shop OBEX P1 Docs P2 Docs Learn Events
SEROUT and Tri-State Data pin — Parallax Forums

SEROUT and Tri-State Data pin

ArchiverArchiver Posts: 46,084
edited 2003-03-03 22:41 in General Discussion
Allan-

From the _BASIC Stamp Programming Manual Version 1.8_ description:
"Dpin is a variable/constant (0-15) that specifies the I/O pin that
will be connected to the synchronous-serial device's data input.
This pin's I/O direction will be changed to output and will remain
in that state after the instruction is completed."

FWIW, I always insert an INPUT instruction between a SHIFTOUT and
SHIFTIN which target the same pin for this reason.

Regards,

Steve

On 3 Mar 03 at 17:48, Allan Lane allan.lane@honeywe wrote:

> ...Does anybody know what 'SHIFTOUT' does to its Data pin once the
> command completes?

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-03-03 17:48
    I recently connected my BS2 and a DS1302 Clock chip.
    I've got them working, no problem.
    My concern is that I'm using a 'SHIFTOUT' to command the 1302
    followed by an immediate 'SHIFTIN' command to read its response --
    and I don't know the state of the 'Data' pin to the DS1302 in between
    the two commands.

    If the 'SHIFTOUT' leaves its data pin in OUTPUT state, then when the
    1302 grabs the pin to drive it for the first data bit back to the BS2
    there is a possibility of contention on the pin, at least until the
    BS2 'SHIFTIN' turns the 'Data' pin into an input.

    I've searched the 2.0c Programming Manual without success. Does
    anybody know what 'SHIFTOUT' does to its Data pin once the command
    completes?

    Thanks in advance, Allan.
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-03 18:03
    At 05:48 PM 3/3/03 +0000, you wrote:
    >I recently connected my BS2 and a DS1302 Clock chip.
    >I've got them working, no problem.
    >My concern is that I'm using a 'SHIFTOUT' to command the 1302
    >followed by an immediate 'SHIFTIN' command to read its response --
    >and I don't know the state of the 'Data' pin to the DS1302 in between
    >the two commands.
    >
    >If the 'SHIFTOUT' leaves its data pin in OUTPUT state, then when the
    >1302 grabs the pin to drive it for the first data bit back to the BS2
    >there is a possibility of contention on the pin, at least until the
    >BS2 'SHIFTIN' turns the 'Data' pin into an input.
    >
    >I've searched the 2.0c Programming Manual without success. Does
    >anybody know what 'SHIFTOUT' does to its Data pin once the command
    >completes?
    >
    >Thanks in advance, Allan.


    Use a 470 Ohm resistor on the BS2 I/O pin. Worst case scenario you
    will only be sinking/sourcing about 10.6mA
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-03 18:37
    Allan,

    Install a resistor (220 to 1000 ohms) between the two pins. That
    way, the short period of contention won't matter. SHIFTOUT does
    leave the pin an output.

    -- Tracy



    >I recently connected my BS2 and a DS1302 Clock chip.
    >I've got them working, no problem.
    >My concern is that I'm using a 'SHIFTOUT' to command the 1302
    >followed by an immediate 'SHIFTIN' command to read its response --
    >and I don't know the state of the 'Data' pin to the DS1302 in between
    >the two commands.
    >
    >If the 'SHIFTOUT' leaves its data pin in OUTPUT state, then when the
    >1302 grabs the pin to drive it for the first data bit back to the BS2
    >there is a possibility of contention on the pin, at least until the
    >BS2 'SHIFTIN' turns the 'Data' pin into an input.
    >
    >I've searched the 2.0c Programming Manual without success. Does
    >anybody know what 'SHIFTOUT' does to its Data pin once the command
    >completes?
    >
    >Thanks in advance, Allan.
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-03 19:33
    Wow, three accurate, helpful answers in a few hours.
    Thanks to all. I'm amazed Parallax 'simplified' their manual to the
    point where it became silent (or ambiguous) on this point. This is
    not to flame anyone, I'm very impressed by their products and support.
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-03 21:32
    A lesson learned:

    Original Question:
    If you connect a Stamp and a DS1302 Clock chip directly, and use the
    SHIFTOUT and SHIFTIN commands to talk to the 1302, isn't there
    contention on the Data pin when you want to read something from the
    1302?

    Answer: Yes, the SHIFTOUT command leaves its Data pin set HIGH, until
    the SHIFTIN command executes and turns the Data pin into an input
    (around 600 uS). The DS1302 will have been trying to drive the pin
    HIGH (no problem), or float it LOW (through an internal 40K ohm
    resistor, also no problem) during this time.

    A cautious designer will put a 200 to 1000 ohm series resistor in the
    data line, to limit the contention current during this time (thanks
    Tracy!)

    Next Question: Why doesn't the 1302 driver burn out without this
    resistor?

    Answer: Because the DS1302 protocol was cleverly designed to ALWAYS
    have a '1' as the last bit sent for a command. I believe the 1302
    data driver WOULD burn out IF the last sent bit was a 0, and the 1302
    tried to drive a 1 (result, short circuit). BUT, since this 'never'
    happens in normal use, the 1302 is preserved. Caution suggests
    putting in the series current limiting resistor just in case.

    Thanks all!
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-03 22:41
    At 09:32 PM 3/3/03 +0000, you wrote:
    >A lesson learned:
    >
    >Original Question:
    >If you connect a Stamp and a DS1302 Clock chip directly, and use the
    >SHIFTOUT and SHIFTIN commands to talk to the 1302, isn't there
    >contention on the Data pin when you want to read something from the
    >1302?
    >
    >Answer: Yes, the SHIFTOUT command leaves its Data pin set HIGH, until
    >the SHIFTIN command executes and turns the Data pin into an input
    >(around 600 uS). The DS1302 will have been trying to drive the pin
    >HIGH (no problem), or float it LOW (through an internal 40K ohm
    >resistor, also no problem) during this time.
    >
    >A cautious designer will put a 200 to 1000 ohm series resistor in the
    >data line, to limit the contention current during this time (thanks
    >Tracy!)
    >
    >Next Question: Why doesn't the 1302 driver burn out without this
    >resistor?
    >
    >Answer: Because the DS1302 protocol was cleverly designed to ALWAYS
    >have a '1' as the last bit sent for a command. I believe the 1302
    >data driver WOULD burn out IF the last sent bit was a 0, and the 1302
    >tried to drive a 1 (result, short circuit). BUT, since this 'never'
    >happens in normal use, the 1302 is preserved. Caution suggests
    >putting in the series current limiting resistor just in case.
    >
    >Thanks all!

    I should point out....."Caution suggests putting in the series current
    limiting resistor just in case" ...Unless speed becomes an issue.

    You don't have to worry about high speed issues with the BS2 or 1302,
    but in other applications it might be something worth considering.
    As resistance increases, slew-rate decreases. See attached GIF...











    [noparse][[/noparse]Non-text portions of this message have been removed]
Sign In or Register to comment.