SERIN SERIN2 Timeout


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2005
    Posts
    53

    Question SERIN SERIN2 Timeout

    I need someone help getting Serin timeout to work.
    If there is no data on PORTB.1 (pin = 0V) after a delay I need to jump out of Serin. I wait for "A" sync and store the next byte M.
    My Serin works until data stops then hangs forever.
    My Serin2 hangs always.

    Test1:
    Pause 110
    SerIn PORTB.1,T2400,["A"],M ' Works until data stops then hangs
    'serin2 PORTB.1,t2400,2000,Test2,[wait("A"),M] ' hangs
    SerOut SO,T2400,[I,line2,#j," ",#M]
    TOGGLE PORTB.4
    GOTO Test1
    Test2:
    SerOut SO,T2400,[I,line2,#j," "]
    TOGGLE PORTB.4
    GOTO Test1

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    This has been covered many times. As long as the input pin is toggling (even just with noise), the timeout will keep being reset. Also, I cannot recall which (but you can easily test this), but if the input is in the wrong state when at idle, it won't time out either. You can force the correct idle state through additional hardware, or by software.

    I remember posting this over a year ago (although I can't seem to find it now) as an example to a Hardware solution...
    Attached Images Attached Images  

  3. #3
    Join Date
    Jun 2005
    Posts
    53


    Did you find this post helpful? Yes | No

    Arrow will serin timeout if data is low and not toggling?

    From what I read the serin & serin2 will not timeout if the input pin is high or toggling.
    My data line is normally low and no noise that I can see on a scope.
    I only need to transfer a byte or 2 of data and I am using an "A" to sync.
    I have attempted T2400, N2400, OT2400, ON2400. I have tried both serin & serin2.

    SerIn PORTB.1,T2400,["A"],M ' Works until data stops then hangs

    'serin2 PORTB.1,t2400,2000,Test2,[wait("A"),M] ' hangs

    I can't fit external gates, so I need a software solution. Right now I can only use the WDT to recover.

    Am I mis-understanding Serin?
    Any recommendations?

    Thanks
    Last edited by markedwards; - 23rd June 2005 at 14:58.

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    But isn't the 'idle' state different whether you are running TRUE or INVERTED mode?

    If you physically short the line low does it stop hanging?

    If you are communicating between two PICs you can always program the sender to drag it's output to the idle state on completion of transmission.

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Inverted mode should idle low.
    True mode should idle high.

    This is really simple to test. Try this;
    Code:
    N9600 CON 16468 ' 9600 bps inverted (idle should be low)
    Timeout CON 1000
    X VAR BYTE
    
    Main:
        serin2 portb.0,16468, Timeout,Label,[wait("A"),X]
        toggle 2 ' Toggle LED on RB2 if ASCII A & byte in X received
        pause 1000 
        goto Main
        
    Label:
        toggle 1  ' Toggle LED on RB1 (if input pin is held at 0 >1000mS)
        goto Main ' Hold the input pin at logic 1 to see what happens.
        
        END
    If the device sending serial data to the PIC is keeping the pin low during idle periods, and you're using true mode with SERIN or SERIN2, then the timeout & label option will not work.

    The active or "not idle" logic state on the serial input pin causes the timeout period to continually be reset, and this causes it to hang forever. This will always happen if random noise or the wrong idle logic is on the serial input pin.

    SerIn PORTB.1,T2400,["A"],M ' Works until data stops then hangs
    This will always hang when data stops. You're instructing the PIC to wait for the ASCII A character, then place the next byte in the M variable. If the wait condition is never met, the PIC will sit & spin waiting for it.

    However, as shown above, you'll need to make sure the device sending data to the PIC is returning the PIC serial input pin to the idle logic state during idle periods, and the communications line is noise free. Otherwise the timeout and label options won't work either.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6
    Join Date
    Jun 2005
    Posts
    53


    Did you find this post helpful? Yes | No

    Smile Serin idle state

    Thanks a million! Idling the Serin pin high fixes the hang.
    I think that will fix my problem. It's not a problem, It's a new feature!
    If communications line is broken the WDT will reset the system.

Similar Threads

  1. Serin2 Timeout
    By tazntex in forum Serial
    Replies: 15
    Last Post: - 15th August 2008, 15:40
  2. Serin vs Serin2
    By The Master in forum mel PIC BASIC
    Replies: 12
    Last Post: - 19th October 2007, 16:50
  3. 16F628A Serin timeout and Timer1
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th March 2006, 23:20
  4. SERIN & Timeout
    By BigWumpus in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 30th October 2004, 07:33
  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