Shop OBEX P1 Docs P2 Docs Learn Events
FullDuplexSerial mode explanation — Parallax Forums

FullDuplexSerial mode explanation

RsadeikaRsadeika Posts: 3,837
edited 2007-02-28 21:20 in Propeller 1
I need somebody to explain to me what does the different mode designations do for me, or for that matter what does it mean.

mode bit 0 = invert rx
mode bit 1 = invert tx
mode bit 2 = open-drain/source tx
mode bit 3 = ignore tx echo on rx

In the PE Kit lab, objects, in the example where it shows you how to work with HyperTerminal it uses Debug.start(31, 30, 0, 57600). The example uses 0 as the mode designation, and everything works as expected. What would I expect to happen if I changed the mode to a 1,2, or 3.

I decided to set up a comm port on my PE kit using three wires, Rx,Tx, and grnd. I am going to use 220 Ohm·resistors on the Rx, and Tx lines. This will be connecting up to Rx, and Tx pins on the other 5V based board. Now the question is, which mode setting would I use and why. And of course I will be using the FullDuplexSerial.spin program to get the two boards to talk to each other.

Thanks

Ray

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-02-27 21:09
    If you want mode bit 0 to be true, use %0001. Mode bit 1 is %0010. Mode bit 2 is %0100 and mode bit 3 is %1000. Combine them as you need to. Normally, the resting state of a serial communications line is HIGH (logic 1). Sometimes, this is the other way around (logic 0 for resting state). In that case, the routines will reverse things if the mode bits are set (invert rx - receive, invert tx - transmit). Usually, both rx and tx are inverted if this mode is used, but not always. Normally, the transmit line is connected to +3.3V or 0V (ground). Sometimes, the transmit line is left open (high impedance) or connected to ground. This is called open-source mode and can be selected with mode bit 2. Sometimes the transmit line is connected to the receive line external to the Propeller and the Propeller will receive everything that's transmitted. Mode bit 3, when set, indicates that a received character should be discarded for every character sent. Normally, this will discard the echoed characters.

    The default mode setting is zero. In your case, this will probably work fine. It depends on the other board.
  • RsadeikaRsadeika Posts: 3,837
    edited 2007-02-28 21:06
    Thanks, Mike (for the record, it was not overkill, as some other poster, in another post,·had mentioned, it was just right), for the good information. I got the comm part to work, now I am talking to my iRobot Create. The next step is to get the PE kit to talk to an SX52 proto board. For that I will probably have to wait until I find some good examples as to how to run a UART VP, in SX/B, at 57600 baud, and run a SIRC VP in the same interrupt, that concept is way over my head.

    The only other question that I have is, in the string command, 0 is not an allowed value, only the 1-255 values are allowed. I tried sending 0 value via byte, but my iRobot Create does not like that, it likes the values to be sent via string, or at least most of the values.·Any insight as to why that may be. As I am typing this, it just came to me, I wonder if the string function uses 0 to terminate the the actual string values.

    Thanks
  • Mike GreenMike Green Posts: 23,101
    edited 2007-02-28 21:20
    Like several other programming languages (C comes to mind), Spin uses a zero byte to terminate a character string constant and routines that take the address of a string and output/transmit it won't transmit a zero byte. You can always use the single byte transmit call xxx.out or xxx.tx to transmit a zero value as in "ser.tx(0)".
Sign In or Register to comment.