Shop OBEX P1 Docs P2 Docs Learn Events
full duplex serial question — Parallax Forums

full duplex serial question

mikeamikea Posts: 283
edited 2012-06-01 17:59 in Propeller 1
I'm sorting out a code problem, and not sure what the zero relates to in this ... Debug.start(31,30,0,9600). 31, 30 are serial to talk to p.c., and 9600 is baud speed, right? Also for next time where would i look to find the docs on my own for code like this and the ASCII codes. E.G. ..13 i think is carriage return.Thanks-mike

Comments

  • BitsBits Posts: 414
    edited 2012-06-01 06:35
    The object has text that mentions what the "0" is for but ill post a brief as well.

    In debug.start(31,30,0,9600) the 0 is to invert RX. Its the mode in how the bits are sent. Google ASCII chart and you will get many pictures you can print out and place next to your monitor.
  • mikeamikea Posts: 283
    edited 2012-06-01 06:43
    cool, thank you Bits. Didn't think to look there. Printout is a good idea.-mike
  • BitsBits Posts: 414
    edited 2012-06-01 07:03
    Here is the chart I use most of the time.
  • Mike GMike G Posts: 2,702
    edited 2012-06-01 07:30
    In debug.start(31,30,0,9600) the 0 is to invert RX
    If I'm not mistaken, the mode parameter of the start method uses bit encoding where bits 0-3 have a purpose.
    bit 3	bit 2	bit 1	bit 0
    ---------------------------------
    0	0	0	0		Not inverted 	(0)
    0	0	0	1		Rx inverted	(1)
    0	0	1	0		Tx Inverted	(2)
    0	0	1	1		Rx Tx inverted	(3)
    
  • BitsBits Posts: 414
    edited 2012-06-01 11:09
    Mike G

    You might be mistaken...
    This is a copy of the comments in the object
    PUB start(rxpin, txpin, mode, baudrate) : okay
    
    
    '' Start serial driver - starts a cog
    '' returns false if no cog available
    ''
    '' 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
    
    So mode 0 inverts rx unless my object is out dated or has been molested in some digital form.
  • ratronicratronic Posts: 1,451
    edited 2012-06-01 11:53
    Bits it only inverts rx if the mode bit 0 is set to 1.
  • BitsBits Posts: 414
    edited 2012-06-01 12:05
    Again in the comments section is clearly states that 0 = invert rx and 1= invert tx. Do I have a different object, we are talking about Full duplex serial right?

    Here is the object.
    Attachment not found.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-06-01 12:05
    bit 0 refers to the least significant bit. If the lsb is 1 then rx is inverted.

    If mode is set to 1 (%00000001) rx is inverted. If mode is set to two (%00000010) tx is inverted. You can invert both by using mode equal to 3 (%00000011).
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-06-01 12:38
    Bits: The code comments you have quoted are a bit misleading. It works as Mike G ad Duane have stated.

    The normal mode is "0" which means neither are inverted. How it works is that RS232 drivers and receivers invert the bits sent and received by the UART. So, in our case, the bits are sent and received by the prop which is acting like a UART. Now, if we connect directly to the FT232RL USB chip, we are again connecting to a UART equivalent. This means we have a direct connection UART to UART, so we omit the RS232 drivers and receivers at each end which cancel each inversion out. Hence, our code does not require inversion.

    However, if we connect directly to an external RS232 device, such as a PC, using just serial resistors and pullup/pulldown (need to think which atm), then you would require FDX to invert both the TX and RX because you have omitted the RS232 driver and receiver. Sometimes this works and sometimes it does not, depending on the actual interface used in the PC (or other RS232 device). This is because you are swtching between +3V3 and GND and the RS232 requires +V and -V (used to be 12-15V, but has been lowered in later RS232 revisions). However, often the chips used these days see > +3V as the +V and GND as the -V.

    So, to recap, if you have a true RS232 connection, and you omit the inversion in hardware (the RS232 driver/receiver) then you need to invert the tx/rx pins accordingly in software. If you omit the inversion in hardware at both ends (i.e. both are at TTL or CMOS levels and not RS232 levels) you do not require software inversion.

    An easy way to remember is if you look at a UART chip, the other pins such as /RTS, /DTR, /CTS, /DCD, /DSR & /RI are all denoted as active low. Then feed these through an RS232 chip which inverts these signals, so +3V becomes -V (~-12V) and GND becomes +V (~+12V). So an active signal is GND which becomes +V in RS232 levels.

    Hope this helps.
  • msrobotsmsrobots Posts: 3,709
    edited 2012-06-01 17:59
    its about bits, Bits.

    Enjoy!

    Mike
Sign In or Register to comment.