Announcement

Collapse
No announcement yet.

asm error : address label duplicated ot different in second pass

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    that's not what I mean ,forget that isr completely





    timer1 isr would count 1 sec per overflow

    lets say the display is updated 4 times per sec via another isr

    the display isr would go

    hun=(timer1 ** 9994)/100
    arraywrite disp,[dec4 sec,".",dec2 hun,0]

    Comment


    • #17
      I can't see the point of having an accurate txco clock and mangling its output by adding or skipping counts. how is that ever going to result in accurate timings ? you are just introducing more error .the concept is flawed .


      the txco accuracy < 2 parts per million, your isr error > 3 parts /1000 (might as well use the internal clock)

      why is this 50 HZ mentioned / why 10mS /why 2.5ms
      how fast does a display really need to be updated [so its not a meaningless blur] ?

      whats more important accurate timing or fancy bluring numbers on a display ?
      Last edited by richard; 08-08-2016, 05:20 AM.

      Comment


      • #18
        well unfortunately i really need to use this isr as it the timer / varables for a lot of things

        all the variables are used directly to display / record times , etc , so to change the approach now is not practical
        there are multiple counters and other timers that use these varables for when and how things are used and displayed

        i have been able to get the exact time of 10ms by using the system clock , and then using osctune to get it exact , plus some padding of 1us within the timer code

        but its only exact while there is no drift in the system osc , and osctune is a only avaiable for the internal sys clock

        i was going to put an external tcxo to the pic , but soon found that would not help alot when can not do fine tuning for timer1 using osctune with an external TCXO

        i cant see a way to pad the isr code to give me small tuning when using an external ref of 32.768khz clock , except by doing what i have been for fine tune and it not nice way to do it

        thanks richard ,

        if you have any further way i might get it more accurate given the current isr then please post

        cheers from perth


        sheldon

        sheldon

        Comment


        • #19
          Originally posted by richard View Post

          the txco accuracy < 2 parts per million, your isr error > 3 parts /1000 (might as well use the internal clock)
          ?
          well if you have an example of how to do the code , that uses varables in the isr as i have it , using the TXCO output that is more accurate than what i am doing now ,

          other wise i think the system clock with the standard ISR is better than using the TXCO and jumping counts and still have a 4us error over 3 cycles

          the system clock can be setup to be accurate , for the time its setup ,

          Txco is consistant accurate , but not exact into any time period of 1/100th,

          Comment


          • #20
            a simple system like this with your txco could easily deliver millisecond accuracy, if the seconds counter is made 24 bit then durations upto 194 days are possible


            simple ,easy adapatable [kiss]

            Code:
            '****************************************************************
            '*  Name    : ?.pbp                                 *
            '*  Author  : richard                                           *
            '*  Notice  :                                                   *
            '*          :                                                   *
            '*  Date    :                                                   *
            '*  Version :    18f25K22     @5.0 volts                        *
            '*  Notes   :                                                   *
            '*          :                                                   *
            '*            
            '****************************************************************
              
            #CONFIG
              CONFIG  FOSC = INTIO67
              CONFIG  PLLCFG = ON
              CONFIG  PRICLKEN = ON
              CONFIG  FCMEN = OFF
              CONFIG  IESO = OFF
              CONFIG  PWRTEN = ON
              CONFIG  BOREN = SBORDIS
              CONFIG  BORV = 190
              CONFIG  WDTEN = ON
              CONFIG  WDTPS = 32768
              CONFIG  CCP2MX = PORTC1
              CONFIG  PBADEN = OFF
              CONFIG  CCP3MX = PORTB5                                
              CONFIG  T3CMX = PORTC0
              CONFIG  HFOFST = ON
              CONFIG  P2BMX = PORTB5
              CONFIG  MCLRE = EXTMCLR
              CONFIG  STVREN = ON
              CONFIG  LVP = OFF
              CONFIG  XINST = OFF
              CONFIG  DEBUG = OFF
              CONFIG  CP0 = OFF
              CONFIG  CP1 = OFF
              CONFIG  CP2 = OFF
              CONFIG  CP3 = OFF
              CONFIG  CPB = OFF
              CONFIG  CPD = OFF
              CONFIG  WRT0 = OFF
              CONFIG  WRT1 = OFF
              CONFIG  WRT2 = OFF
              CONFIG  WRT3 = OFF
              CONFIG  WRTC = OFF
              CONFIG  WRTB = OFF
              CONFIG  WRTD = OFF
              CONFIG  EBTR0 = OFF
              CONFIG  EBTR1 = OFF
              CONFIG  EBTR2 = OFF
              CONFIG  EBTR3 = OFF
              CONFIG  EBTRB = OFF
            #ENDCONFIG
                            
             DEFINE OSC 64 
                    
             include "dt_ints-18c.bas"   ;  mod to work with mplabx
             Include "REENTERPBP-18.bas"
            
            ASM
            INT_LIST macro
                    INT_Handler TMR1_INT , _TOCK,pbp,yes
                    INT_Handler TMR3_INT , _TICK,pbp,yes
                   endm
                    INT_CREATE
                ENDASM 
            
               DEFINE DEBUG_REG PORTB
               DEFINE DEBUG_BIT 7
               DEFINE DEBUG_BAUD 9600
               DEFINE DEBUG_MODE 0
            
            T3CON=$31
            T1CON=$8f
            trisc=$ff
            trisb=$fc
            ANSELB=0
            ANSELC=0
            OSCCON=$70
            OSCTUNE.6=1
            TRISB.7=0  ;DEBUG
            LATB.7=1   ;DEBUG
            pause 2000
            @timer1 =TMR1L
            @timer3 =TMR3L
            timer1 var word ext
            timer3 var word ext
            seconds var word
            sn var word      ; now seconds
            tl var word
            te var word
            tn var word    ;no tmr1 ticks
            dup var bit
            dn  var word  ;display timer counter
            
            @ INT_ENABLE  TMR1_INT
            @ INT_ENABLE  TMR3_INT
            Debug "Start",13 ,10
            seconds=0
            dn=0
            mainloop:
            
            if dup then
            gosub getnow
            
            te= tn-tl
            tl=tn
            Debug "loop t ",dec te,13 ,10,10
            te=tn**1998
            sn=sn+te/1000
            Debug "elapsed t ",dec sn,".",dec3 te//1000, 13 ,10,10
            dup=0
            endif
            
             
            goto mainloop         
            
            
            getnow:
             tn= timer1
             pie1.0=0
             sn = seconds
             pie1.0=1
             return
            
            
            TOCK: 
             latb.0 = !latb.0
             seconds=seconds+2
            
            @    INT_RETURN 
             
               
            
            TICK: 
            t3con.0=0
            timer3=timer3+25536      ;20mS
            t3con.0=1
            dn=dn+1
            if dn>39 then
            dn=0
            dup=1
            endif
             
            
            @    INT_RETURN

            Comment


            • #21
              24 bit version , should be good for 99 days

              Code:
              '****************************************************************
              '*  Name    : ?.pbp                                 *
              '*  Author  : richard                                           *
              '*  Notice  :                                                   *
              '*          :                                                   *
              '*  Date    :                                                   *
              '*  Version :    18f25K22     @5.0 volts                        *
              '*  Notes   :                                                   *
              '*          :                                                   *
              '*            
              '****************************************************************
                
              #CONFIG
                CONFIG  FOSC = INTIO67
                CONFIG  PLLCFG = ON
                CONFIG  PRICLKEN = ON
                CONFIG  FCMEN = OFF
                CONFIG  IESO = OFF
                CONFIG  PWRTEN = ON
                CONFIG  BOREN = SBORDIS
                CONFIG  BORV = 190
                CONFIG  WDTEN = ON
                CONFIG  WDTPS = 32768
                CONFIG  CCP2MX = PORTC1
                CONFIG  PBADEN = OFF
                CONFIG  CCP3MX = PORTB5                                
                CONFIG  T3CMX = PORTC0
                CONFIG  HFOFST = ON
                CONFIG  P2BMX = PORTB5
                CONFIG  MCLRE = EXTMCLR
                CONFIG  STVREN = ON
                CONFIG  LVP = OFF
                CONFIG  XINST = OFF
                CONFIG  DEBUG = OFF
                CONFIG  CP0 = OFF
                CONFIG  CP1 = OFF
                CONFIG  CP2 = OFF
                CONFIG  CP3 = OFF
                CONFIG  CPB = OFF
                CONFIG  CPD = OFF
                CONFIG  WRT0 = OFF
                CONFIG  WRT1 = OFF
                CONFIG  WRT2 = OFF
                CONFIG  WRT3 = OFF
                CONFIG  WRTC = OFF
                CONFIG  WRTB = OFF
                CONFIG  WRTD = OFF
                CONFIG  EBTR0 = OFF
                CONFIG  EBTR1 = OFF
                CONFIG  EBTR2 = OFF
                CONFIG  EBTR3 = OFF
                CONFIG  EBTRB = OFF
              #ENDCONFIG
                              
               DEFINE OSC 64 
               PRECISION       CON 3 SYSTEM        
               include "dt_ints-18c.bas"
               Include "REENTERPBP-18.bas"
               Include "N-Bit_MATH.pbp"
              
              ASM
              INT_LIST macro
                      INT_Handler TMR1_INT , _TOCK,pbp,yes
                      INT_Handler TMR3_INT , _TICK,pbp,yes
                     endm
                      INT_CREATE
                  ENDASM 
              
                DEFINE DEBUG_REG PORTB
                 DEFINE DEBUG_BIT 7
                 DEFINE DEBUG_BAUD 9600
                 DEFINE DEBUG_MODE 0
              
              T3CON=$31
              T1CON=$8f
              trisc=$ff
              trisb=$fc
              ANSELB=0
              ANSELC=0
              OSCCON=$70
              OSCTUNE.6=1
              TRISB.7=0  ;DEBUG
              LATB.7=1   ;DEBUG
              pause 2000
              @timer1 =TMR1L
              @timer3 =TMR3L
              timer1 var word ext
              timer3 var word ext
              seconds var byte[3]
              sn var byte[3]
              tmp   var byte[3]
              res   var byte[3] 
              
              elday     var byte
              elhour    var byte
              elmin     var byte
              elsec     var byte
              elmillie  var word
              
              tl var word
              te var word
              tn var word
              dup var bit
              dn  var word
              
              @ INT_ENABLE  TMR1_INT
              @ INT_ENABLE  TMR3_INT
              Debug "Start",13 ,10
              @  MATH_CLR  _seconds   ; clear an N-Bit variable   seconds=0
              
              dn=0
              mainloop:
              
              if dup then
              gosub getnow
              
              te= tn-tl
              tl=tn
              Debug "loop t ",dec te,13 ,10,10
              
              Debug "elapsed t ",dec elday,":",dec2 elhour,":",dec2 elmin,":",dec2 elsec,".",dec3 elmillie, 13 ,10,10
              dup=0
              endif
              
               
              goto mainloop         
              
              
              getnow:
               tn= timer1
               pie1.0=0
               @  MOVE?PP  _seconds, _sn ;  sn = seconds    
               pie1.0=1
              elmillie=tn**1998 
              if    (elmillie/1000) then
              elmillie=elmillie//1000 
              @  MATH_INC  _sn 
              endif
              ;days
              @  MOVE?CP 86400, _tmp
              @  MATH_DIV  _sn, _tmp, _res 
              @  MOVE?PB  _res, _elday
              @  MOVE?PP REG_Z, _sn
              ;hours
              @  MOVE?CP 3600, _tmp
              @  MATH_DIV  _sn, _tmp, _res 
              @  MOVE?PB  _res, _elhour
              @  MOVE?PW REG_Z, _te
              ;min
              elmin=te/60
              ;sec
              elsec= te//60
              
              return
              
               
               
              
              
              TOCK: 
               latb.0 = !latb.0
               @  MATH_INC  _seconds
               @  MATH_INC  _seconds
              @    INT_RETURN 
              
              
              
              TICK: 
              t3con.0=0
              timer3=timer3+25536      ;20mS
              t3con.0=1
              dn=dn+1
              if dn>39 then
              dn=0
              dup=1
              endif
               
              
              @    INT_RETURN
              Last edited by richard; 08-08-2016, 11:30 PM.

              Comment


              • #22
                thanks richard

                i have also been looking at roman blacks works with timers

                some intreresting work in getting the system clock accurate as well

                Comment


                • #23
                  here's a stopwatch demo using a 32bit counter for 244uS ticks , its a lot simpler and can deliver millie second accuracy

                  Code:
                  '****************************************************************
                  '*  Name    : ?.pbp                                 *
                  '*  Author  : richard                                           *
                  '*  Notice  :                                                   *
                  '*          :                                                   *
                  '*  Date    :                                                   *
                  '*  Version :    18f25K22     @5.0 volts                        *
                  '*  Notes   :   32k ext xtal clk for timer1                     *
                  '*          :                                                   *
                  '*            
                  '****************************************************************
                    
                  #CONFIG
                    CONFIG  FOSC = INTIO67
                    CONFIG  PLLCFG = ON
                    CONFIG  PRICLKEN = ON
                    CONFIG  FCMEN = OFF
                    CONFIG  IESO = OFF
                    CONFIG  PWRTEN = ON
                    CONFIG  BOREN = SBORDIS
                    CONFIG  BORV = 190
                    CONFIG  WDTEN = ON
                    CONFIG  WDTPS = 32768
                    CONFIG  CCP2MX = PORTC1
                    CONFIG  PBADEN = OFF
                    CONFIG  CCP3MX = PORTB5                                
                    CONFIG  T3CMX = PORTC0
                    CONFIG  HFOFST = ON
                    CONFIG  P2BMX = PORTB5
                    CONFIG  MCLRE = EXTMCLR
                    CONFIG  STVREN = ON
                    CONFIG  LVP = OFF
                    CONFIG  XINST = OFF
                    CONFIG  DEBUG = OFF
                    CONFIG  CP0 = OFF
                    CONFIG  CP1 = OFF
                    CONFIG  CP2 = OFF
                    CONFIG  CP3 = OFF
                    CONFIG  CPB = OFF
                    CONFIG  CPD = OFF
                    CONFIG  WRT0 = OFF
                    CONFIG  WRT1 = OFF
                    CONFIG  WRT2 = OFF
                    CONFIG  WRT3 = OFF
                    CONFIG  WRTC = OFF
                    CONFIG  WRTB = OFF
                    CONFIG  WRTD = OFF
                    CONFIG  EBTR0 = OFF
                    CONFIG  EBTR1 = OFF
                    CONFIG  EBTR2 = OFF
                    CONFIG  EBTR3 = OFF
                    CONFIG  EBTRB = OFF
                  #ENDCONFIG
                                  
                   DEFINE OSC 64 
                   PRECISION       CON 4 SYSTEM        
                   include "dt_ints-18c.bas"
                   Include "REENTERPBP-18.bas"
                   Include "N-Bit_MATH.pbp"
                  
                  ASM
                  INT_LIST macro
                          INT_Handler TMR1_INT , _TOCK,pbp,yes
                          INT_Handler TMR3_INT , _TICK,pbp,yes
                         endm
                          INT_CREATE
                      ENDASM 
                  
                  DEFINE DEBUG_REG PORTB
                  DEFINE DEBUG_BIT 7
                  DEFINE DEBUG_BAUD 9600
                  DEFINE DEBUG_MODE 0
                  
                  T3CON=$31
                  T1CON=$Bf
                  trisc=$ff
                  trisb=$fc
                  ANSELB=0
                  ANSELC=0
                  OSCCON=$70
                  OSCTUNE.6=1
                  TRISB.7=0  ;DEBUG
                  LATB.7=1   ;DEBUG
                  pause 2000
                  @timer1 =TMR1L
                  @timer3 =TMR3L
                  timer1      var word ext
                  timer3      var word ext
                  ticks     var byte[4]
                  sn          var byte[4]
                  tmp         var byte[4]
                  res         var byte[4] 
                  start_sec   var byte[4]
                  stop_sec    var byte[4] 
                  start_tn    var word
                  stop_tn     var word
                  sw          var  portc.7
                  elday       var byte
                  elhour      var byte
                  elmin       var byte
                  elsec       var byte
                  elmillie    var word
                  tl          var word
                  te          var word
                  tn          var word
                  dup         var bit
                  tip         var bit
                  sub         var bit
                  dn          var word
                  
                  
                  @ INT_ENABLE  TMR1_INT
                  @ INT_ENABLE  TMR3_INT
                  Debug "Start",13 ,10
                  @  MATH_CLR  _ticks   ; clear an N-Bit variable   seconds=0
                  @  MOVE?CP 354000000,  _ticks    ;day rollover  test
                  dn=0
                  tip=0
                  dup=0
                  sub=0
                  
                  mainloop:
                  
                  if !sw  then
                      if tip  then
                          gosub get_now
                         
                          @  MOVE?PP _sn ,_stop_sec 
                          gosub dhms_time
                          Debug 13,10,"stopwatch end ",9,dec elday,":",dec2 elhour,":",dec2 elmin,":",dec2 elsec,".",dec2 elmillie
                          gosub delta_time 
                          
                           gosub dhms_time
                          
                          Debug 13,10,"elapsed    ",9,dec elday,":",dec2 elhour,":",dec2 elmin,":",dec2 elsec,".",dec2 elmillie
                          tip=0
                         
                      else
                          gosub get_now
                         
                          @  MOVE?PP _sn ,_start_sec 
                          gosub dhms_time
                          Debug 13,10,"stopwatch go ",9,dec elday,":",dec2 elhour,":",dec2 elmin,":",dec2 elsec,".",dec2 elmillie
                          tip=1 
                      endif
                      while  !sw 
                      wend
                  endif
                  if dup then
                      gosub get_now
                      te=tn-te
                      gosub dhms_time
                      Debug 13,10,"loop t ",dec te,13 ,10,10
                      Debug 13,10,"current t ",dec elday,":",dec2 elhour,":",dec2 elmin,":",dec2 elsec,".",dec2 elmillie, 13 ,10,10
                      te=tn
                      dup=0
                  endif
                  
                   
                  goto mainloop         
                  
                  
                  get_now:
                      tn= timer1
                      pie1.0=0
                      @  MOVE?PP  _ticks, _res    
                      pie1.0=1
                      @  MOVE?WP _tn, _tmp
                      @  MATH_ADD  _res , _tmp , _sn   ;  sn = ticks
                      
                  return
                   
                   
                  
                      
                  dhms_time:       
                      latb.0 = 1
                      ;days
                      @  MOVE?CP 354098360, _tmp
                      @  MATH_DIV  _sn, _tmp, _res 
                      @  MOVE?PB  _res, _elday
                      @  MOVE?PP REG_Z, _sn
                      ;hours
                      @  MOVE?CP 14754098, _tmp
                      @  MATH_DIV  _sn, _tmp, _res 
                      @  MOVE?PB  _res, _elhour
                      @  MOVE?PP REG_Z, _sn
                      ;min
                      @  MOVE?CP 245901, _tmp
                      @  MATH_DIV  _sn, _tmp, _res 
                      @  MOVE?PB  _res, _elmin
                      @  MOVE?PP REG_Z, _sn
                      ;sec
                      @  MOVE?CP 4098, _tmp
                      @  MATH_DIV  _sn, _tmp, _res 
                      @  MOVE?PB  _res, _elsec
                      @  MOVE?PW REG_Z, _tl
                      elmillie=tl**1599       ;244uS ticks
                      latb.0 = 0
                  return    
                      
                      
                     
                      
                      
                  
                  delta_time:
                  
                      @  MATH_SUB  _stop_sec , _start_sec , _sn
                   
                  
                  return       
                      
                     
                      
                     
                      
                  
                   
                   
                  
                  
                  TOCK: 
                      
                      @  MOVE?CP 65536, _tmp
                      @  MATH_ADD  _ticks , _tmp , _res
                      @  MOVE?PP _res, _ticks
                  @    INT_RETURN    
                   
                  
                  
                  
                  TICK: 
                      t3con.0=0
                      timer3=timer3+25536      ;20mS
                      t3con.0=1
                      dn=dn+1
                      if dn>399 then
                          dn=0
                          dup=1
                      endif
                  @    INT_RETURN

                  Comment


                  • #24
                    hi richard i am trying to follow your 24bit ver so i can undertand it better with comments , can you fillin some blanks in the comments


                    Code:
                    '*  Notes   : 24 bit ver                                        *
                    '*          :                                                   *
                    '*          :  downloaded so i can comment and try understand it    *
                    '*                                                              *
                    '****************************************************************
                    
                                    
                     DEFINE OSC 64 
                            
                     include "dt_ints-18c.bas"   ;  mod to work with mplabx   THIS NEW , NEED TO LOOK AT mplabx ver  and changes 
                     Include "REENTERPBP-18.bas"
                    
                    ASM
                    INT_LIST macro
                            INT_Handler TMR1_INT , _TOCK,pbp,yes       ; timer1 overflow int call routine 
                            INT_Handler TMR3_INT , _TICK,pbp,yes       ; timer3 overflow int call routine  
                           endm
                            INT_CREATE
                        ENDASM 
                    
                       DEFINE DEBUG_REG PORTB       ; setup debug port of terminal 
                       DEFINE DEBUG_BIT 7
                       DEFINE DEBUG_BAUD 9600
                       DEFINE DEBUG_MODE 0
                    
                    T3CON=$31 'set 1:8 prescale     ' T3CON  = %00110001     ' Timer 3 ,bit7-6 = TMR3 CLK source 00 = Instuction Clk(Fosc/4),01 =sys clk,10=ext clk,11=cap sense osc
                              ' enable timer        ' bit5-4 = TMR3 prescale 00= 1:1,01= 1:2 ,10=1:4,,11=1:8   ,bit3=0 LP off,bit2=1 no sync ext CLK ,bit1= 0 n/a,Bit0=0 Timer 1 on/off
                              ' place 8 bit loads
                              ' uses sytem clk 
                                                     
                    T1CON=$8f ' set timer1 ext clk , t1clki pin (rising edge)   - external clock ref connected to pin 
                              ' set 1:1 prescale              
                              ' set no sync with ext clk, 
                              ' 16bit operation 
                              ' enable timer
                    
                    
                    trisc=$ff
                    trisb=$fc
                    ANSELB=0
                    ANSELC=0
                    OSCCON=$70
                    OSCTUNE.6=1
                    TRISB.7=0  ;DEBUG
                    LATB.7=1   ;DEBUG
                    pause 2000
                    
                    @timer1 =TMR1L                ; place preload lower 8bit   into 16bit value into timer1 var 
                    @timer3 =TMR3L                ; place preload lower 8bit   inot 16bit value into timer3 var 
                    timer1 var word ext           ' setup the word ext varable 
                    timer3 var word ext           ' setup word ext varable 
                    
                    seconds var word
                    sn var word      ; now seconds
                    tl var word                      ' ???
                    te var word                      ' time ela
                    tn var word      ;no tmr1 ticks    ???
                    dup var bit                       '???
                    dn  var word     ;display timer counter
                    
                    @ INT_ENABLE  TMR1_INT       ; start the interupts enable routines 
                    @ INT_ENABLE  TMR3_INT
                    Debug "Start",13 ,10
                    
                    
                    seconds=0
                    dn=0
                    ' ---------- Main program ---------- 
                     mainloop:
                    
                       if dup then                                                  ; if flag = 1 then 
                           gosub getnow                                             ' do sub 
                           te= tn-tl                                                ' te = timer1 ticks - 
                           tl=tn
                           Debug "loop t ",dec te,13 ,10,10
                           te=tn**1998                                             ' ?????
                           sn=sn+te/1000                                           ' seconds elapsed  = current seconds elapsed + timer1 ticks / 1000 ????????????
                           Debug "elapsed t ",dec sn,".",dec3 te//1000, 13 ,10,10
                           dup=0
                       endif
                     
                     goto mainloop         
                    
                    '-----------sub Routines --------------
                    ' 
                     getnow:
                        tn= timer1               ' save timer1 ticks to varable 
                        pie1.0=0                 ' clear timer 1 interupt - why now ??? 
                        sn = seconds             ' save seconds count to varable for display
                        pie1.0=1                 ' set  timer1 interupt  - why now  ???
                     return
                    
                    ' ---- ISR for timer1 ------------
                    TOCK: 
                     latb.0 = !latb.0                      '  timer1 clock input when low ? ???
                     seconds=seconds+2                     ' increment secs by 2 for every count of input ?
                    
                    @    INT_RETURN 
                        
                    ' ----- ISR for timer3 -------------
                    TICK: 
                    t3con.0=0                               ' turn off timer3 
                    timer3=timer3+25536      ;20mS          ' ??? not sure where these figures come from for preload value into timer 3 
                    t3con.0=1                               ' turn on timeer 3 
                    dn=dn+1                                 ' increment display timer counter 
                    if dn>39 then                           ' if display count > 39 then - why 39 ???
                        dup=1                               ' set flag so that it loads timer1 value ???
                    endif
                     
                    
                    @    INT_RETURN

                    Comment


                    • #25
                      thanks richard i have sent you a pm ,

                      Comment


                      • #26
                        the 24bit version is a bit awkward so i will explain the 32 bit version


                        there are two timers used tmr1 and tmr3

                        tmr1 is driven by the 32khz xtal extosc / 8 that gives 1 tick per 244uS.
                        on overflow the isr tock adds 0xffff to the 32bit system time ticks , this occurs every 15.8 seconds
                        this timer is never interfered with so it can maintain accuracy.

                        the system time a timestamp is the top 24bits of ticks + timer1

                        the get_now sub will get the system time for you and load the "timestamp" into the 32bit var sn


                        tmr3 is only used to time display printouts

                        its isr tick reloads the 20ms tconstant and every nth time sets a flag to indicate the display needs a refresh [nth = 40 or 400 depending on version]


                        delta_time
                        calculates 32bit difference between to timestamps



                        dhms_time
                        breaks a 32 bit timestamp into days,hours,minutes,seconds,hundtedths or millies if req [depending on version]

                        to time an interval simply save a begining timestamp ,and ending timestamp call delta_time then use dhms_time to
                        split it into hms quantities
                        Last edited by richard; 08-09-2016, 09:42 PM.

                        Comment

                        Working...
                        X