PIR1.0 stays ever 1 ?!


Closed Thread
Results 1 to 8 of 8

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    The problem may not be in the measurement technique.

    More than likely, it's due to two things. The first being ON INTERRUPT. Since it waits until the current Line of code has finished before it branches to the interrupt handler, you never know when the interrupt will actually be handled. If a Long Running statement like SEROUT is in progress when an interrupt occurs, it may be several milliseconds before it gets to the handler.

    The second problem comes from just Loading the required "Count" into the timer on each interrupt. This causes it to lose however many cycles it took to get to the handler.

    If you ADD the "Count" to the current timer value, it can compensate for the lost time. The way it works is ... Once the timer overflows from 65535 and creates an interrupt, the timers value is now 0, and the timer is still running. Once it finally gets to the interrupt handler, the timer value shows exactly how long it took to get there. So now, if you add "Count" to the timers value (plus the time it actually took to add it), you'll have accounted for everything, and Time will count normaly.

    Using the ADD technique with ON INTERRUPT will definately help. But, I would suggest moving to ASM interrupts if you need to keep Long Term time accuracy, or Short term precision.

    HTH,
      Darrel

    P.S. Since you mentioned it. Melanie's Olympic Timer shows one way to do the ADD thing. See the SetTimer routine.
    Last edited by Darrel Taylor; - 8th March 2006 at 23:16. Reason: Olympic sized Omission

Similar Threads

  1. Thermo 7 segments - little problem
    By fratello in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 27th July 2013, 07:31
  2. RS485 bus - starting probem
    By wurm in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th January 2010, 13:35
  3. 32 bit square root
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 6th May 2009, 03:37
  4. one line led light make image
    By bioul in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 12:19
  5. HSERIN doesn´t work
    By wurm in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th July 2007, 14:23

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