Elapsed Timer findings - Page 2


+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 41 to 48 of 48
  1. #41
    Join Date
    Aug 2003
    Posts
    985


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: Elapsed Timer findings

    Consider it tested
    GPS PPS signal (yellow trace) compared to DT’s Elapsed Timer (red trace)... port bit pulse every hundred interrupts at 100Hz in the ISR (1 PPS also).
    Pic is clocked with 10MHz rubidium module.
    At 1uS resolution on the scope, even one instruction cycle error would cause the clocks to run away from each other very quickly!




  2. #42
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,837


    Did you find this post helpful? Yes | No

    Default Re: Elapsed Timer findings

    Moved my question to a new thread:

    https://www.picbasic.co.uk/forum/sho...-Timer-preload
    Last edited by Demon; - 23rd August 2024 at 01:21.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

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


    Did you find this post helpful? Yes | No

    Default Re: Elapsed Timer findings

    Quote Originally Posted by Art View Post
    ...For the 20MHz example where the constant is 03B7h, it's the reverse of this:

    FFFFh - 03B7h = C348h (49992 decimal),
    49992 + 8 = 50000 (it must take eight instruction cycles to reload the timer)
    50000 / 10000 = 5
    5 x 4 = 20MHz

    ... Art.

    For the next guy that needs to incorporate the Prescaler into Art's formula (like when you want to calculate Preload for faster oscillators):

    65535 - (((( MHz / Prescaler ) / 4 ) x 10000 ) - 8 )

    Then set T1CON prescaler accordingly.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

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


    Did you find this post helpful? Yes | No

    Default Re: Elapsed Timer findings

    did you see this

    Code:
    '***************************************************************************
    '*  Name    : Elapsed_INT-18.bas                                           *
    '*  Author  : Darrel Taylor                                                *
    '*  Date    : JUL 11, 2006 : 7/11/2010                                     *
    '*  Version : 1.2                                                          *
    '*  Notes   : Must have DT_INTS-18.bas loaded first                        *
    '*   ver 1.2: Now works at any OSC frequency without using the prescaler   *
    '***************************************************************************

    the pic16 ver can work up to and including 32MHz without the need of a prescaler if necessary

    Code:
    '****************************************************************
    '*  Name    : Elapsed_INT.bas                                   *
    '*  Author  : Darrel Taylor                                     *
    '*  Date    : Jan 10, 2006                                      *
    '*  Notes   : Must have DT_INTS-??.bas loaded first             *
    '****************************************************************
    DISABLE DEBUG
    ; syntax =     Handler  IntSource,        Label, Type, ResetFlag?
    DEFINE  Elapsed_Handler  TMR1_INT,  _ClockCount,  PBP,  yes
    ; the above define can be used in the INT_LIST macro, if desired (optional)
    
    
    Ticks    var byte   ' 1/100th of a second
    Seconds  var byte
    Minutes  var byte
    Hours    var byte
    Days     var word
    
    
    SecondsChanged   var bit
    MinutesChanged   var bit
    HoursChanged     var bit
    DaysChanged      var bit
    SecondsChanged = 1
    MinutesChanged = 1
    
    
    Goto OverElapsed
    
    
    ' ------------------------------------------------------------------------------
    ' To calculate a constant for a different crystal frequency - see this web page
    ' http://www.picbasic.co.uk/forum/showthread.php?t=2031
    ' ------------------------------------------------------------------------------
    Asm
      IF OSC == 4                       ; Constants for 100hz interrupt from Timer1
    TimerConst = 0D8F7h                 ; Executed at compile time only
      EndIF
      If OSC == 8
    TimerConst = 0B1E7h
      EndIF
      If OSC == 10
    TimerConst = 09E5Fh
      EndIF
      If OSC == 16
    TimerConst = 063C7h
      EndIF
      If OSC == 20
    TimerConst = 03CB7h
      EndIF
      If OSC == 32
    TimerConst = 25539
      EndIF
    Last edited by richard; - 23rd August 2024 at 04:03.
    Warning I'm not a teacher

  5. #45
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,837


    Did you find this post helpful? Yes | No

    Default Re: Elapsed Timer findings

    Nope. The one I just downloaded today (just to be certain) only went up to 20 MHz.

    Code:
      IF OSC == 4                       ; Constants for 100hz interrupt from Timer1
    TimerConst = 0D8F7h                 ; Executed at compile time only
      EndIF
      If OSC == 8
    TimerConst = 0B1E7h
      EndIF
      If OSC == 10
    TimerConst = 09E5Fh
      EndIF
      If OSC == 16
    TimerConst = 063C7h
      EndIF
      If OSC == 20
    TimerConst = 03CB7h
      EndIF

    Can you get to that number using Art's formula?

    The link in the comments is dead.
    Last edited by Demon; - 23rd August 2024 at 04:35.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  6. #46
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,837


    Did you find this post helpful? Yes | No

    Default Re: Elapsed Timer findings

    Maybe I have obsolete includes. These are the versions I have:

    Code:
    '***************************************************************************
    '*  Name    : ReEnterPBP.pbp                                               *
    '*  Author  : Darrel Taylor                                                *
    '*  Version : 3.4  (8/13/2010)                                             *
    '*  Notes   : Allows re-entry to PBP from an ASM interrupt                 *
    '*          : Must have DT_INTS-14.bas loaded first                        *
    '***************************************************************************
    '*  ver 3.4 (8/13/2010)                                                    *
    '*           Changed Restore to use 1 less stack level                     * 
    '*  ver 3.3 (1/16/2010)                                                    *
    '*           compatability with PIC16F1 chips                              *
    '*  ver 3.2 
    '*           Bug Fix, RS1/RS2 were being restored incorrectly              *
    '***************************************************************************
    Code:
    '***************************************************************************
    '*  Name    : DT_INTS-14.bas                                               *
    '*  Author  : Darrel Taylor                                                *
    '*  Version : 1.10 (8/13/2010)                                             *
    '*  Date    : OCT 13, 2009                                                 *
    '***************************************************************************
    '* REV 1.10  Fixes Duplicate label error when Handlers cross page boundary *
    '*           Fixes error with 16F1's and MPLAB 8.53 (high)                 *
    '* REV 1.00  Completely re-written, with optimization and F1 chips in mind *
    '* REV 0.93  Fixed CMIF and EEIF problem with older PIC's                  *
    '*           that have the Flags in PIR1 instead of PIR2                   *
    '* Rev 0.92  solves a "Missed Interrupt" and                               *
    '*           banking switching problem                                     *
    '***************************************************************************
    I have the same version of Elapsed_INT.bas as you.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  7. #47
    Join Date
    May 2013
    Location
    australia
    Posts
    2,452


    Did you find this post helpful? Yes | No

    Default Re: Elapsed Timer findings

    Quote Originally Posted by Demon View Post


    Can you get to that number using Art's formula?
    nope

    looks like i snuck in 2:1 prescale with nill comments or anything

    picmulticalc says it all

    Name:  Untitled.jpg
Views: 39
Size:  97.8 KB


    i don't know where the pic18 vers came from , its not something i would ever use these days
    Last edited by richard; - 23rd August 2024 at 05:33.
    Warning I'm not a teacher

  8. #48
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,837


    Did you find this post helpful? Yes | No

    Default Re: Elapsed Timer findings

    I'm happy you shared that image. I have the Interrupt Frequency at 10 usec, not 10 msec. I suppose that could have just been a default value.

    I'm using the timer to count Ticks between encoder pulses. I control when the Elapsed Timer starts and stops, so do I really want such a fast interrupt that probably will take resources from other operations?

    I'm assuming that the Interrupt Frequency triggers code in the background.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

Similar Threads

  1. Elapsed Timer Demo
    By Darrel Taylor in forum Code Examples
    Replies: 111
    Last Post: - 29th October 2012, 17:39
  2. SPWM and Elapsed Timer
    By CocaColaKid in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 8th May 2008, 03:16
  3. Darrel Taylor Elapsed Timer
    By rwskinner in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 13th March 2008, 01:22
  4. 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 : 8

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