Shop OBEX P1 Docs P2 Docs Learn Events
fdserial between two propeller 'flip' modules.; A Reopening - Page 6 — Parallax Forums

fdserial between two propeller 'flip' modules.; A Reopening

12346»

Comments

  • what is true mode serial?

  • JonnyMacJonnyMac Posts: 9,440
    edited 2025-08-11 22:34

    True mode serial has a high idle state, a low start bit, data bits match (sent LSB first), and a high stop bit.

    From your code:

      FTD.start(11, 10, %0000, 9600)
    

    The 3rd parameter designates the mode:

    '' Start serial driver (uses a cog, returns 1 to 8 if successful)
    '' -- rxp.... receive pin (0..31)
    '' -- txp.... transmit pin (0..31)
    '' -- mode... %xxx1 = invert rx
    ''            %xx1x = invert tx
    ''            %x1xx = open-drain/open-source tx
    ''            %1xxx = ignore tx echo on rx (for half-duplex on one pin)
    

    (These comments are from jm_fullduplexserial.spin which is a small modification of the original fullduplexserial.spin from Chip)

    With a mode parameter of %0000 you not going to invert either pin, and you're not counting on a pull-up to generate a "1" on the line. That said, sometimes we'll still put a pull-up on RX so that a disconnection doesn't case false RX bits.

  • @JonnyMac said:
    With a mode parameter of %0000 you not going to invert either pin, and you're not counting on a pull-up to generate a "1" on the line. That said, sometimes we'll still put a pull-up on RX so that a disconnection doesn't case false RX bits.

    Since the normal idle state is high, a pull-up will make a disconnection appear just like an idle line. So isn't a pull-down on RX more correct because it will make a physical break condition appear as a BREAK condition?

  • JonnyMacJonnyMac Posts: 9,440
    edited 2025-08-11 23:37

    Since the normal idle state is high, a pull-up will make a disconnection appear just like an idle line. So isn't a pull-down on RX more correct because it will make a physical break condition appear as a BREAK condition?

    Only if your serial driver can handle the break condition. I've not seen a version of FDS that does.

  • bbrienbbrien Posts: 600
    edited 2025-08-13 03:02

    I would assume that if I use on the hand box that I should also use on the mount side even though every thing is half duplex serial. also I don't need any pull ups on the tx pins, but still I should use on the rx pins.

  • Your setup never sends data from mount to handbox. You could cut that line.

  • For JonnyMac, can you explain how the "%0000 calls a high or low when there are no pull-ups or pull-downs ,I confused. Still no serial.

  • JonnyMacJonnyMac Posts: 9,440
    edited 2025-08-23 12:54
    pub start(rxp, txp, mode, baud)
    
    '' Start serial driver (uses a cog, returns 1 to 8 if successful)
    '' -- rxp.... recieve pin (0..31)
    '' -- txp.... transmit pin (0..31)
    '' -- mode... %xxx1 = invert rx
    ''            %xx1x = invert tx
    ''            %x1xx = open-drain/open-source tx
    ''            %1xxx = ignore tx echo on rx (for half-duplex on one pin)
    

    Mode bits 0 and 1 define how the bits are received or transmitted; 0 for True mode, 1 for inverted. In True mode, the idle state of transmit is high, a start bit is low, the data bits match (i.e., a 0 bit is low, a 1 bit is high), and the stop bit is high. These states get flipped when using inverted mode.

    When mode bit 2 is set, the Propeller will only drive the TX line in one direction; the line is floated in the other. For True mode, the TX pin is only driven low for start and 0 bits. This means that the TX pin needs a pull-up. When using inverted mode, the TX pin is only driven high (start bit and 0 bits) so it requires a pull-down. Open-drain/open-source is mostly used for 1-wire serial connections.

    Which is why mode 3 is available; for a one-wire connection everything transmitted will end up in the devices receive buffer, so setting Mode bit 3 flushes our own data from the receive buffer so that it's not mixed in with what the other device sends.

    If you're using True mode, the TX line is driven so it doesn't require a pull-up. That said, one should put a pull-up on the RX pin to hold it high if there is a disconnect between devices. Imagine if an RX pin becomes disconnected from the other device and goes low; this will look like a start bit to the receiver. The software UART in FDS doesn't have the ability to detect a break condition, a floating low on the RX pin could fill the receive buffer with a bunch of zeroes.

    Here's a real-world example of a pull-up on RX (R5). This is a typical RS-485 circuit in which the RS-485 can be in transmit mode or receive mode. In transmit mode the RO pin (receive out) is floated. For this reason there is a pull-u on that line so that the Propeller sees the idle state properly while it is transmitting.

    If you're using True mode the transmit pin is driven. Still a broken line between on P1 and the other could create a problem a pull-up on the RX pin would prevent a break from becoming a break condition.

  • If I read this correctly then I would set the mode bits to %1100, this would make the TX line pull high on the master but I should pull the RX line down with a resistor on the mount.

  • JonnyMacJonnyMac Posts: 9,440

    You didn't read it correctly. What I told you several posts ago is to put a pull-up on the RX pin of each P1. That way a cable disconnect won't case a bunch of zeros to stuff the receive buffer on each side.

  • sorry, I am confused . the receive pin in the hand box isn't used nor the tx pin in the mount. one way communication only

  • JonnyMacJonnyMac Posts: 9,440

    Oh, for crying out loud... if you have true mode receive pin, put a pull-up on it. End of story. You have on side transmitting (driven) and the other side receiving. Put the pull-up on the receive side to prevent a break condition if the two sides become disconnected.

  • With the %1100 There should be no pull-up on the TX if I am right, is that correct.

  • JonnyMacJonnyMac Posts: 9,440
    edited 2025-08-31 01:04

    You're kidding, right? You are absolutely not correct. And since you cannot be bothered, let's look at the document comments for the FDS start() method.

    As you're setting BIT2 in your configuration, the TX pin is working in open-drain mode WHICH REQUIRES A PULL-UP!!! Put a 10K to 3.3V on the serial line on both sides.

  • bbrienbbrien Posts: 600
    edited 2025-08-31 01:23

    I guess I don't understand the open drain/open source. I'll be back on line tomorrow.

Sign In or Register to comment.