Timeout function


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Post Tmr0

    Properly doing the job would involve the use of one of the PIC's internal timers. TMRO could be used, load it with a value and let it overflow a few times. Possibly the best person to help you with this would be Darrel. I think he might have some good code that's directly applicable in this area. In fact, the code that you already have
    looks remarkably like a working timeout proc
    <br/>
    Last edited by T.Jackson; - 7th May 2007 at 11:49.

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Once In_STB = 0 then you might have had half a second passed not a full second.

    Or, if a full second is passed and you are in DataDone, then you might still have had In_STB = 1; then you come back immediately (possibly).

    Or, having a timer module running inside a WHILE statement will keep you and your Timer module locked in that WHILE statement. Thus, having a "PAUSE 1000" will do the same job for you cause the statement is locked anyway.

    --------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Default Synchronous

    PAUSE is synchronous - meaning nothing else can be processed during its execution. At least not PBP code. Asynchronous on the other hand - (which is what you want in this case) - typically something that runs in the background, usually hardware-based interrupts, timers and so forth.
    <br/>

  4. #4
    Join Date
    May 2007
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    can you please supply me with a example for my code using the timer.

  5. #5
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Post

    Take a look at this thread: http://www.picbasic.co.uk/forum/showthread.php?t=2129

    RTC has some primary TMR0 fundamentals that might help point you in the right direction.

  6. #6
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by T.Jackson View Post
    PAUSE is synchronous - meaning nothing else can be processed during its execution. At least not PBP code. Asynchronous on the other hand - (which is what you want in this case) - typically something that runs in the background, usually hardware-based interrupts, timers and so forth.
    <br/>
    This is what I said in a different way.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer View Post
    Once In_STB = 0 then you might have had half a second passed not a full second.

    Or, if a full second is passed and you are in DataDone, then you might still have had In_STB = 1; then you come back immediately (possibly).

    Or, having a timer module running inside a WHILE statement will keep you and your Timer module locked in that WHILE statement. Thus, having a "PAUSE 1000" will do the same job for you cause the statement is locked anyway.

    --------------------------
    You could check 'Pause 1' for 1000 counts...that'll only lock up the program for 1 ms at a time, and end up giving a timeout of a bit over 1 second.

  8. #8
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    You could check 'Pause 1' for 1000 counts...that'll only lock up the program for 1 ms at a time, and end up giving a timeout of a bit over 1 second.

    So the question is, does johnmiller want to have an independent counter running int the background? the sample code above seems to say "No".

    If we follow the sample code above, then the same code logic would also work with PAUSE 1000 or Pause 1 with 1000 counts as Skimask said.

    Tomato or Potaito.
    or was it tomato or tomaito
    -----------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  9. #9
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer View Post
    So the question is, does johnmiller want to have an independent counter running int the background? the sample code above seems to say "No".

    If we follow the sample code above, then the same code logic would also work with PAUSE 1000 or Pause 1 with 1000 counts as Skimask said.

    Tomato or Potaito.
    or was it tomato or tomaito
    -----------
    That's what I'm thinking...and since the O/P said it doesn't have to be too accurate, that's why I suggested the Pause 1 w/ 1000 counts. He'll get 1000 1ms pauses, and the extra cycles used will bring it up to over a second, but well short of 2 seconds. He can trim the 1000 counts value later easily if needed.

  10. #10
    Join Date
    May 2007
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    well I don't need it to be accurate in that time frame (0.9-2sec) but I can't pause it in the while. So my best guess it a timer, but I can't seem to be able to do it that way

  11. #11
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by johnmiller View Post
    well I don't need it to be accurate in that time frame (0.9-2sec) but I can't pause it in the while. So my best guess it a timer, but I can't seem to be able to do it that way
    How long can you actually pause?
    Instead of a 1,000 count Pause, you could use a 1,000,000 PauseUs. Surely that would be fast enough to do what you want to do within 5-10us, which we still don't know what that is...

Similar Threads

  1. Serin2 Timeout
    By tazntex in forum Serial
    Replies: 15
    Last Post: - 15th August 2008, 15:40
  2. Need help with timeout
    By Christopher4187 in forum General
    Replies: 1
    Last Post: - 10th June 2006, 15:38
  3. 16F628A Serin timeout and Timer1
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th March 2006, 23:20
  4. Serialin timeout
    By Nick in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 18th April 2005, 15:21
  5. Random function - How to limit it ??
    By martarse in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 30th November 2004, 14:05

Members who have read this thread : 0

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