Simple Timer question


Closed Thread
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Jul 2009
    Posts
    33

    Default Simple Timer question

    Hello everyone
    I failed miserably to get my head round HSERIN/HSEROUT yesterday so I am trying a new approach. I really need some background timer running so that I can set a time out a bit like this:

    Main:

    if portb.0 = 1 then gosub dostuff 'a pin gets waggled

    'if 3 minutes is up then do something here

    goto main


    gosub dostuff

    'reset the timer back to 0

    return

    Basically under normal circumstances pins will be going high and low and each time they do I want to set the timer back to zero, it is only if there is inactivity that I want to flag it, but do it in the background while the main code is executing. I have been trying to find a simple timer example that applies to me but can't quite understand what I need.

    Thanks

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Lightbulb Simple Timer Answer

    Code:
    INCLUDE "Elapsed.bas"
    
    Gosub ResetTime    ' Reset Time to  0d-00:00:00.00    
    Gosub StartTimer   ' Start the Elapsed Timer
    
    Main:
        if portb.0 = 1 then gosub dostuff 'a pin gets waggled
        
        IF MinutesChanged THEN
            MinutesChanged = 0
            IF Minutes = 3 THEN  
               'if 3 minutes is up then do something here
               
                Gosub ResetTime    ' Reset Time to  0d-00:00:00.00    
            ENDIF
        ENDIF
    goto main
        
        
    dostuff:
        ; waggle as desired
        
        Gosub ResetTime    ' Reset Time to  0d-00:00:00.00    
    return
    DT

Similar Threads

  1. a simple boxe timer (code included)
    By hozone in forum Code Examples
    Replies: 24
    Last Post: - 13th October 2008, 12:57
  2. really simple, dumb question
    By picster in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 3rd March 2007, 22:02
  3. Simple "backround" timer
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 12th November 2005, 05:11
  4. Timer Question 16f877
    By Bonxy in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th November 2005, 08:40
  5. Timer / CCP Question
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd November 2005, 08:22

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