Serin2 Timeout


Closed Thread
Results 1 to 16 of 16

Thread: Serin2 Timeout

Hybrid View

  1. #1

    Default Serin2 Timeout

    Would someone please explain in simple terms on how to use the Timeout with Serin2. The PBP manual says this:

    "An optional Timeout and Label may be included to allow the program
    to continue if a character is not received within a certain amount of time.
    Timeout is specified in 1 millisecond units. If the serial input pin stays in
    the idle state during the Timeout time, the program will exit the SERIN2
    command and jump to Label."

    Right now I am using this:

    loop1:
    SERIN2 serpin,16780,[wait(254),address1,address2,mydata1,mydata2,chk_su m]
    Return

    Would I do something like this for timeout to be 10mS and to jump to label godosomething?
    loop1:
    SERIN2 serpin,16780,10, godosomething,[wait(254),address1,address2,mydata1,mydata2,chk_su m]
    Return

    Also, is it also a good idea to use the flowpin?

    Thanks Everyone

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    Your time out code looks correct.

    The flow pin depends on your application. Myself, with the things I do, 9600 baud and lower, I have not had to use it.
    Last edited by mackrackit; - 13th August 2008 at 15:21.
    Dave
    Always wear safety glasses while programming.

  3. #3

    Default

    Thanks for the reply, is there anyway to set this up for 4800bps?
    Last edited by tazntex; - 13th August 2008 at 16:20.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    Look in the manual under SERIN2, it gives a formula and a sample table. Compare this to appendix A.
    Dave
    Always wear safety glasses while programming.

  5. #5
    skimask's Avatar
    skimask Guest

    Default

    I'm beginning to think somebody doesn't have the little green book.
    And if he/she does actually have the little green book, it hasn't been opened and/or read and/or studied much...

  6. #6

    Default

    Well, looking at SERIN2 and Appendix A, with the formula being (1000000/)-20
    Appendix A states:
    2400 Driven Inverted None 16780
    9600** Driven Inverted None 16468
    taking the formula and coming up with 188.3333333333etc...
    I figure by looking at the examples 16780-188=16592.

    SERIN2 serpin,16780,[wait(254),address1,address2,mydata1,mydata2,chk_su m]
    changed to this:
    SERIN2 serpin,16592,[wait(254),address1,address2,mydata1,mydata2,chk_su m]
    So am I correct by saying 48000 bps would be 16592?

    Thank you

  7. #7
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by tazntex View Post
    Well, looking at SERIN2 and Appendix A, with the formula being (1000000/)-20
    Appendix A states:
    2400 Driven Inverted None 16780
    9600** Driven Inverted None 16468
    taking the formula and coming up with 188.3333333333etc...
    I figure by looking at the examples 16780-188=16592.

    SERIN2 serpin,16780,[wait(254),address1,address2,mydata1,mydata2,chk_su m]
    changed to this:
    SERIN2 serpin,16592,[wait(254),address1,address2,mydata1,mydata2,chk_su m]
    So am I correct by saying 48000 bps would be 16592?

    Thank you
    That's what the PDF says (what about the little green book?).
    A better explanation of the bits used in the SERIN2 mode number are in the SERIN2 section itself.

  8. #8
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    Quote Originally Posted by tazntex View Post
    Well, looking at SERIN2 and Appendix A, with the formula being (1000000/)-20
    Appendix A states:
    2400 Driven Inverted None 16780
    9600** Driven Inverted None 16468
    taking the formula and coming up with 188.3333333333etc...
    I figure by looking at the examples 16780-188=16592.

    SERIN2 serpin,16780,[wait(254),address1,address2,mydata1,mydata2,chk_su m]
    changed to this:
    SERIN2 serpin,16592,[wait(254),address1,address2,mydata1,mydata2,chk_su m]
    So am I correct by saying 48000 bps would be 16592?

    Thank you
    Nope.

    The numbers for the mode setting have been converted to decimal. We need to look at this from a binary point of view. If you do not have a handle on base2, things will be difficult with computers. The computer only understands two things, ON and OFF as in a switch, and most times with micros we can get away with thinking of 8 switches in a group, (or pins)

    As you know with you PIC, the group of 8 is represented as bits 0 - 7.
    With the SERIN2 modes we are talking about 16 switches, bits 0 - 15.

    The table at SERIN2 in the manual gives the first 12 (0-12)bits of the mode and a formula to find this number.
    Code:
    Baud        0-12 bits  Binary
    2400        396         0000110001100
    4800        188         0000010111100
    Now we have bits 13 - 15.
    Bit 13 is for parity. 0=None 1=Even
    Bit 14 is for conversion. 0=True 1=Inverted
    Bit 15 is the Output. 0=Driven 1=Open

    Go to appendix A and look at Mode Number 16780. We will build this from scratch.
    Bit 15 is Driven = 0
    Bit 14 is Inverted = 1
    Bit 13 is No parity = 0
    Take bits 0-12 from above 2400 baud and put it all together.
    0100000110001100
    and convert to Decimal = 16780

    Now for Driven Inverted None 4800.
    Bits 15 - 13
    010
    Bits 0-12 from above 4800
    0000010111100
    Put it together
    0100000010111100
    Convert to Decimal
    16572 is the Mode Number for Driven Inverted None 4800 Baud.

    I hope

    Here is a page to do the conversions.
    http://acc6.its.brooklyn.cuny.edu/~g.../nav2tool.html
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. GPS $GPRMC to PIC16F684. Need help with SERIN2
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 27th November 2009, 09:47
  2. Serin2 and Timeout to Label
    By f0ster52 in forum Serial
    Replies: 2
    Last Post: - 10th April 2009, 03:29
  3. 18f242 serin2 timeout
    By Armadus in forum Serial
    Replies: 1
    Last Post: - 28th July 2007, 22:41
  4. SERIN SERIN2 Timeout
    By markedwards in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 23rd June 2005, 18:59
  5. Serin2 Timeout, how it works?
    By Fossil in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th March 2004, 10:09

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts