Temporary central repository of Darrel Taylor's works (including Mr E's Multicalc)


Results 1 to 40 of 55

Threaded View

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

    Default Temporary central repository of Darrel Taylor's works (including Mr E's Multicalc)

    Scroll down to this post for a list of ZIP files:
    http://www.picbasic.co.uk/forum/show...286#post130286

    Darrel's site is down so his links no longer work. Some can be found at the archive:

    14 bit: http://web.archive.org/web/201201100...-14/intro.html

    18 bit: http://web.archive.org/web/201009201...S-18/home.html
    ------------------------------------------------------------------------------------------------------------

    Elapsed Timer Demo

    Attached to this post is a Zip file that contains a "Drop-In" elapsed timer that uses Timer1 and interrupts. It's waaay down there at the bottom of all this dribble. This may get rather long winded, so my first suggestion is to scroll down to the bottom of this post and check out the file then come back and read this post later.

    --------------------- ----------------------- -----------------------------
    The files contained in the Zip are:

    Test_Elapsed_SER.pbp ' Demo of Elapsed Timer using serout2 command and HyperTerminal
    Test_Elapsed_LCD.pbp ' Demo of Elapsed Timer using an LCD
    Elapsed.bas ' Elapsed Timer include file
    ASM_INTS.bas ' Assembly language Interrupt Stubs

    Note: These files are intended to be used on 14-bit core PICS (12F, 16C and 16F) that have a TIMER1 module.
    Note2: They are written for use as the only interrupt in the program. If you need to use other interrupts as well, the program will have to be modified before it will work.
    Note3: It will NEVER work in conjunction with PBP's ON INTERRUPT statement.

    In it's simplest form, this is all it takes to use the Elapsed Timer:
    Code:
        Include "Elapsed.pbp"
        Gosub ResetTime    ' Reset Time to  0d-00:00:00.00
        Gosub StartTimer   ' Start the Elapsed Timer
    This will create a Clock counting at 1/100 seconds. It runs in the background of PBP without any other program intervention required.

    The time is kept in the variables:
    Code:
        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
    The time can be easily displayed with a single line:
    Code:
        LCDout $FE,2, dec Days,"d-",dec2 Hours,":",dec2 Minutes,":",dec2 Seconds
    For each of the variables (Seconds, Minutes, Hours and Days) there is a flag that indicates when the value of that variable has changed.
    The Flags are:
    Code:
        SecondsChanged   var bit
        MinutesChanged   var bit
        HoursChanged     var bit
        DaysChanged      var bit
    So, if you wanted to display the time like a clock, you could wait until SecondsChanged = 1, display the time, then reset the flag.
    Code:
        Loop1:
            if SecondsChanged = 1 then
               LCDout $FE,2, dec Days,"d-",dec2 Hours,":",dec2 Minutes,":",dec2 Seconds
               SecondsChanged = 0
            endif
        Goto Loop1
    If you only wanted to display the time each minute instead of every second just do the same thing using the MinutesChanged flag.
    Code:
        Loop1:
            if MinutesChanged = 1 then
               LCDout $FE,2, dec Days,"d-",dec2 Hours,":",dec2 Minutes<br>           MinutesChanged = 0
            endif
        Goto Loop1
    The timer can be Stopped and Started, like a stopwatch.
    Code:
        Gosub StopTimer
        Gosub StartTimer
    --------------------- ----------------------- -----------------------------
    The Elapsed.bas include file also Includes another file, ASM_INTS.bas This file can also be used in your other programs as well. It handles the "Context Saving" that is required for any Assembly language interrupt.

    It contains 2 macros:
    INT_START
    Saves the W, STATUS, PCLATH and FSR registers. This can be used at the beginning of your Interrupt routine.

    INT_RETURN
    Restores the W, STATUS, PCLATH and FSR registers after the Interrupt routine is finished and then returns from the Interrupt (RETFIE).

    Using it in a normal Assembly language interrupt might look something like this:

    Code:
        Define  INTHAND  INT_CODE    ' Tell PBP Where the code starts on an interrupt
    ASM
    INT_CODE
        INT_START                ' Save Context
            ... Your Interrupt routine goes here ...
        INT_RETURN               ' Restore Context
    EndAsm
    Well, I guess that covers most of it. if I've missed anything, or you still have questions, please don't hesitate to ask.

    Happy holidays,
    Attached Files Attached Files
    Last edited by Demon; - 23rd June 2015 at 16:26.

Similar Threads

  1. Darrel Taylor Interrupts and MultiCalc
    By AvionicsMaster1 in forum General
    Replies: 6
    Last Post: - 14th February 2012, 06:18
  2. Question on Mister E's PIC MultiCalc.
    By Dick Ivers in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 9th December 2011, 13:37
  3. Darrel Taylor's SPWM code usage
    By Homerclese in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 28th July 2010, 14:13
  4. using darrel taylor's instant interrupts
    By Michael Wakileh in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 31st July 2007, 04:07
  5. Replies: 18
    Last Post: - 23rd May 2006, 05:57

Members who have read this thread : 9

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