Elapsed Timer findings


Results 1 to 40 of 48

Threaded View

  1. #8
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

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

    I was playing with DT_Analog, and random variable set to 0 when I call GetADC.
    This was happen only with long variable enabled.
    So quick look and here is what happened:
    Code:
    #IF  __LONG__
        DTadAccum    VAR LONG ; local - 32-bit sample accumulator
    #ELSE
        DTadAccum    VAR WORD[2]     ; local - 32-bit sample accumulator
    #ENDIF
    If I use PBPL then assembler use this line
    DTadAccum VAR LONG ; local - 32-bit sample accumulator
    And that is fine... Just declaring LONG var.
    But later in code when Darrel clears accumulator:
    Code:
    DTadAccum = 0 : DTadAccum[1] = 0     ; clear the accumulator
    So where is located DTadAccum[1]?
    - 4 bytes after DTadAccum, and where was located my variables that get cleared after calling GetADC? You guessed...

    Solution:
    Replace
    Code:
    DTadAccum = 0 : DTadAccum[1] = 0    ; clear the accumulator
    with
    Code:
    #IF  __LONG__
         DTadAccum = 0  ; clear the accumulator
    #ELSE
        DTadAccum = 0 : DTadAccum[1] = 0  ; clear the accumulator
    #ENDIF
    And that's all.
    Last edited by pedja089; - 15th April 2015 at 12:29.

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 : 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