Elapsed timer not working as expected at 64MHz


Closed Thread
Results 1 to 40 of 56

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,680


    Did you find this post helpful? Yes | No

    Default Re: Elapsed timer not working as expected at 64MHz

    you may like to re-examine that I just tried it on a pic1845k20 @64 MHz and the int is @2.5mS as expected , sheldons mod just adds 100th capability doesn't it ?

    the seconds inc on every 400th interrupt the ticks are not meant to be 10mS
    Last edited by richard; - 23rd December 2014 at 05:57. Reason: better explanition

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Elapsed timer not working as expected at 64MHz

    From http://web.archive.org/web/201206151...8/elapsed.html

    The time is kept in the variables:
    --------------------------------------------------------------------------------

    Ticks var byte ' 1/100th of a second
    Seconds var byte ' 0-59
    Minutes var byte ' 0-59
    Hours var byte ' 0-23
    Days var word ' 0-65535
    But a tick is not 2.5ms.

    Robert

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Elapsed timer not working as expected at 64MHz

    Quote Originally Posted by richard View Post
    you may like to re-examine that I just tried it on a pic1845k20 @64 MHz and the int is 2.5mS as expected , sheldons mod just adds 100th doesn't it

    the ticks only inc on every 4th interrupt

    What happens when you start/stop the timer after 5 ticks using the original include?

    I get this using the new include:
    Name:  Saleae 64MHz 5 ticks.PNG
Views: 1329
Size:  22.6 KB

    Code:
    MainProgram:
    
        if T1CON.0 = 0 then
            PortD.3 = 1
            GOSUB StartTimer
        endif
    
        if OneHundreth = 5 then
            PortD.3 = 0
            GOSUB StopTimer                    ' Stop the Elapsed Timer
            GOSUB ResetTime                     ' Reset Time to  0d-00:00:00.00
        endif
    
        goto MainProgram
    Robert

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,680


    Did you find this post helpful? Yes | No

    Default Re: Elapsed timer not working as expected at 64MHz

    its a clock not a stopwatch , if you really need to measure wee small times like that there are better ways.
    to get the fractional part of the seconds multiply t1post with ticks and / 4

Similar Threads

  1. I2CRead & I2CWrite not working as expected
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 30
    Last Post: - 27th October 2021, 18:36
  2. PORTB.3 Input not working as expected.
    By BobEdge in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 5th March 2013, 09:58
  3. Elapsed Timer Demo
    By Darrel Taylor in forum Code Examples
    Replies: 111
    Last Post: - 29th October 2012, 17:39
  4. SPWM and Elapsed Timer
    By CocaColaKid in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 8th May 2008, 03:16
  5. DT Elapsed Timer
    By rwskinner in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 9th March 2008, 23:17

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