Announcement

Collapse
No announcement yet.

asm error : address label duplicated ot different in second pass

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

  • asm error : address label duplicated ot different in second pass

    HI guys , i am trying to get this to work in asm , but it wont compile and gives the above error on (notload4) label

    all i want is it to jump to that label when the CPFSGT of varable T_CNT >3
    or a return to calling macro

    but i cant see how / what it want to allow it to compile correctly


    Code:
    ; -------------- calc timer load Constants -------------------------------
     ASM
     CLRF T_CNT                       ;  clear T_Cnt AT START
    TimerConst = 81                  ; 81 x 30.5us cycles from timer 1 clock 
    TimerConst = 65536 - TimerConst  ; set value for timer1 preload
    ;----------------- TimerConst value select ---------------------------
    TIME_CONST  macro 
         MOVLW   LOW(TimerConst)       ;  1
         ADDWF   TMR1L,F, 0            ;  1    
         BTFSC   STATUS,C              ;  1/2
         INCF    TMR1H,F, 0            ;  1
         MOVLW   HIGH(TimerConst)      ;  1
         ADDWF   TMR1H,F, 0            ;  1
         endm                                                            
    ;-----------------  ADD TimerConst to TMR1H:TMR1L -------------------------
    ADD2_TIMER   macro
         BCF     T1CON,TMR1ON, 0       ;  1 Turn off timer
         TIME_CONST                    ;  get the base time const and load it into timer 1 
         INCF T_CNT,F                  ;  Increment T_cnt
         MOVLW 3                       ;  set 3 for value to compare ???
         CPFSGT T_CNT                  ;  compare T_cnt > 3 - skip over label if greater  ?????
         GOTO notload4                 ;  if not greater than 3 then goto label 
         MOVLW 1                       ;  value to be subtracted from const 
         SUBWF TMR1L,F, 0              ;  subtract 1 from the const load value on the 4th time load 
         CLRF T_CNT                    ;  clear T_Cnt
    notload4
         endm
    
    ; -----------------  ADD TimerConst to TMR1H:TMR1L and restart TIMER1 ------
    RELOAD_TIMER  macro
         ADD2_TIMER
         BSF     T1CON,TMR1ON, 0       ;  1   Turn TIMER1 back on  (8 cycles)
         endm
    
    ; -----------------  Load TimerConst into TMR1H:TMR1L ----------------------
    LOAD_TIMER  macro
         MOVE?CT  0, T1CON,TMR1ON
         MOVE?CB  0, TMR1L
         MOVE?CB  0, TMR1H
         ADD2_TIMER
         endm
     ENDASM

  • #2
    Code:
    ADD2_TIMER   macro  
         BCF     T1CON,TMR1ON, 0       ;  1 Turn off timer
         TIME_CONST                    ;  get the base time const and load it into timer 1 
         INCF T_CNT,F                  ;  Increment T_cnt
         MOVLW 3                       ;  set 3 for value to compare ???
         CPFSGT T_CNT                  ;  compare T_cnt > 3 - skip over label if greater  ?????
         GOTO notload4                 ;  if not greater than 3 then goto label 
         MOVLW 1                       ;  value to be subtracted from const 
         SUBWF TMR1L,F, 0              ;  subtract 1 from the const load value on the 4th time load 
         CLRF T_CNT                    ;  clear T_Cnt
    notload4
         endm
    try this
    Code:
    ADD2_TIMER   macro
        local notload4
         BCF     T1CON,TMR1ON, 0       ;  1 Turn off timer
         TIME_CONST                    ;  get the base time const and load it into timer 1 
         INCF T_CNT,F                  ;  Increment T_cnt
         MOVLW 3                       ;  set 3 for value to compare ???
         CPFSGT T_CNT                  ;  compare T_cnt > 3 - skip over label if greater  ?????
         GOTO notload4                 ;  if not greater than 3 then goto label 
         MOVLW 1                       ;  value to be subtracted from const 
         SUBWF TMR1L,F, 0              ;  subtract 1 from the const load value on the 4th time load 
         CLRF T_CNT                    ;  clear T_Cnt
    notload4
         endm

    Comment


    • #3
      thanks richjard

      it worked

      i have been looking though a lot of examples but never saw that command before

      i assume that that keeps the label local to the macro , but the asm error did not give a hint to that

      also looking at how DT did the LOAD_TIMER macro
      , why does he start the timer , then load 0 in the registers , then go and reload them again with the constants ,
      it seems strange to start a timer , then load 0 , then reload them with the correct value , all while the timer is instructed to to run ?

      sheldon

      Comment


      • #4
        Originally posted by longpole001 View Post
        i have been looking though a lot of examples but never saw that command before

        i assume that that keeps the label local to the macro , but the asm error did not give a hint to that
        it kinda does { notload4 unequal in second pass } indicates multiple instances



        also looking at how DT did the LOAD_TIMER macro
        i think there are multiple versions , some just reset the timer with the timer const while others add the const to the timer.
        the later option minimises isr timing jitter

        Comment


        • #5
          hi richard ,
          this ASM was setup to allow a 32.768khz clock (30.5ms )from the RTC that has the TXCO , that is connected externally to scoc , Timer1 is setup to use scoc as it clock
          osctune , and added delays in the code dont seem to effect the out put timing now the timer1 is ext clocked

          what i want is the cleanest and perfect 2.5ms tick i can get so i get the 10ms for the 1/100th timing
          problem is 30.5ms is not going to give me a nice 2.5ms time

          what i have measured is when the timer1 is loaded with 81 and 4 x reloads(total count = 324) , i get 49.9532hz = 20.01873754ms which is 18.73754us more than 20ms cycle on the output pin for monitoring
          when i change the reload to be 3 x81 + 1 x82 ( total count 325) , i get 50.1058ms which is 19.95776936ms , which is -42.23064us less than 20ms

          2x 18.73754us = 37.47508us = 2 x (4 loads=1 cycle) of error rate above 20ms per/cycle
          1 x-42.23064 is removed from the error rate when 1 cycle of count 325 is done leaving an error rate over 3cycles of -4.75556 us

          thus i have 11 x 81 load counts with 1 load of 82 counts so over 3 x1/100th , the time is as accurate as i can from this clock

          this not that bad , but i would like to be 0 error , but i can seem to find a number combination of loads with correction load that i can get it do that

          the scope freq count jumps as low as 49.9967hz and as high as 50.0071hz while monitoring the output pin with this load values above

          have you a idea how to get it to a lower error rate


          cheers

          Sheldon
          Last edited by longpole001; 08-07-2016, 10:08 PM.

          Comment


          • #6
            theoretically :-

            324 counts =9.882 mS error -118uS

            328 counts =10.004mS error 4uS


            82 counts
            82 +counts
            82 +counts
            81 +counts
            327 counts = 9.9735 mS error -26.5uS

            actual count req is 81.92 I don't think you can never really even that up over such a short period for a steady exact 10mS interval, mind you the real accuracy of the xtal might also be challenged . you would need a recently calibrated accurate freq counter for really meaningful testing


            conclusion
            32k txco is not a good choice for the task
            Last edited by richard; 08-07-2016, 11:30 PM.

            Comment


            • #7
              the other way to go about it is

              txco :- tmr1 , count timer1 overflows into elapsed seconds counter (secs)

              to make a timing. either reset tmr1 or record its value then reset secs or record its value

              at the end , record tmr1_ and secs_ . Elapsed time = [ sec_ -secs ] Seconds + [ ( tmr1_ - tmr1) * 15.25] uS

              Comment


              • #8
                yes the 32khz txco iand it other clock out puts of 1hz,1.024khz,4.096khz, 8.192khz all dont look great to get me a 2.5ms clock

                i did actully go looking for a nice txco for this requirements but none that are less than 50khz , which is the max input freq for timer1

                Comment


                • #9
                  Originally posted by longpole001 View Post
                  yes the 32khz txco iand it other clock out puts of 1hz,1.024khz,4.096khz, 8.192khz all dont look great to get me a 2.5ms clock

                  i did actully go looking for a nice txco for this requirements but none that are less than 50khz , which is the max input freq for timer1
                  why 2.5 mS , there are 655 [15.25uS] ticks in 1/100 of a sec using my "other" option , no jitter . vastly better resolution

                  Comment


                  • #10
                    mainly becuase i need a resolution of 1/100th for display and records

                    Comment


                    • #11
                      if i could set a a fixed delay to trim up the value needed would be great , but so far the only way i can do that is using the source clock resolution

                      Comment


                      • #12
                        TIMER1/655= 100th's of a second

                        Comment


                        • #13
                          ah ok i thikn i follow you now you say count 655 on timer 1 and just display the 1/100th

                          Comment


                          • #14
                            not quite , when you update the display the 100 ths figure is timer1/655
                            timer1 ** 9994 woyl give you 100 th s x 100

                            Comment


                            • #15
                              well i tried loading 327 x 30.5 = 9.9735ms in theory , measured at 49.9537hz ,
                              when i removed /4 in the code for the pulse , so no gains over the last approch , and when i do 326 as a count i get 50.1005hz
                              , again the same as when i had i added an extra count

                              Code:
                               ASM
                               CLRF T_CNT                       ;  clear T_Cnt AT START
                              TimerConst = 326                 ; 81 x 30.5us cycles from timer 1 clock 
                              TimerConst = 65536 - TimerConst  ; set value for timer1 preload
                              ;----------------- TimerConst value select ---------------------------
                              TIME_CONST  macro 
                                   MOVLW   LOW(TimerConst)       ;  1
                                   ADDWF   TMR1L,F, 0            ;  1    
                                   BTFSC   STATUS,C              ;  1/2
                                   INCF    TMR1H,F, 0            ;  1
                                   MOVLW   HIGH(TimerConst)      ;  1
                                   ADDWF   TMR1H,F, 0            ;  1
                                   endm                                                            
                              ;-----------------  ADD TimerConst to TMR1H:TMR1L -------------------------
                              ADD2_TIMER   macro
                                   local notload4                ; keep the label local to the macro 
                                   BCF     T1CON,TMR1ON, 0       ;  1 Turn off timer
                                   TIME_CONST                    ;  get the base time const and load it into timer 1 
                              ;     INCF T_CNT,F                  ;  Increment T_cnt
                              ;     MOVLW 11                      ;  set 11 for value to compare ???
                              ;     CPFSGT T_CNT                  ;  compare T_cnt > 3 - skip over label if greater  ?????
                              ;     GOTO notload4                 ;  if not greater than 3 then goto label 
                              ;     MOVLW 1                       ;  value to be added to const 
                              ;     ADDWF TMR1L,F, 0              ;  add 1 to the const load value on the 4th time load to decrease time 
                              ;     CLRF T_CNT                    ;  clear T_Cnt
                              notload4
                                   endm
                               ; -----------------  ADD TimerConst to TMR1H:TMR1L and restart TIMER1 ------
                              RELOAD_TIMER  macro
                                   ADD2_TIMER
                                   BSF     T1CON,TMR1ON, 0       ;  1   Turn TIMER1 back on  (8 cycles)
                                   endm
                              
                              ; -----------------  Load TimerConst into TMR1H:TMR1L ----------------------
                              LOAD_TIMER  macro
                                   MOVE?CT  0, T1CON,TMR1ON
                                   MOVE?CB  0, TMR1L
                                   MOVE?CB  0, TMR1H
                                   ADD2_TIMER
                                   endm
                               ENDASM
                              
                              ' ------[ This is the Interrupt Handler ]-----------------------------------
                              EL_ClockCount:
                              
                              @ RELOAD_TIMER  
                              ;  EL_Ticks = EL_Ticks  + 1    ; each tick is 2.5ms
                               
                              
                                IF EL_CountDown = 1 THEN             ' if countdown = 1 then count down enabled    
                                     EL2_allow = 0                    ' force no extra timeres when countdown else will display incorect overtime/timeleft : note need to allow count up otpion when conting down in extra timers 
                               ;      if EL_ticks // T1PS =  0  THEN   ' if modulas of tips (4) = 0 
                                         IF EL_Days = 0 THEN
                                            IF EL_Hours = 0 THEN
                                              IF EL_Minutes = 0 THEN
                                                IF EL_Seconds = 0 THEN
                                                   if EL_100th = 0 then 
                                                      EL_ZERO = 1
                                                   ENDIF
                                                ENDIF
                                              ENDIF
                                            ENDIF
                                         endif
                                         if EL_100th > 0 then
                                            EL_100th = EL_100th - 1 
                                            EL_100thChanged = 1 
                                         else  
                                            IF EL_Seconds > 0  THEN
                                               EL_Seconds = EL_Seconds - 1
                                               EL_100TH = 100
                                               EL_SecondsChanged = 1
                                            ELSE
                                              IF EL_Minutes > 0 THEN
                                                 EL_Minutes = EL_Minutes - 1
                                                 EL_Seconds = 59
                                                 EL_SecondsChanged = 1
                                                 EL_MinutesChanged = 1
                                              ELSE 
                                                  IF EL_Hours_EN = 1 and EL_Hours > 0 THEN
                                                     EL_Hours = EL_Hours - 1
                                                     EL_Minutes = 59
                                                     EL_Seconds = 59
                                                     EL_SecondsChanged = 1
                                                     EL_MinutesChanged = 1
                                                     EL_HoursChanged = 1
                                                  ELSE
                                                      IF EL_Days_EN = 1 and EL_Days > 0 THEN
                                                         EL_Days = EL_Days - 1
                                                         EL_Hours = 23
                                                         EL_Minutes = 59
                                                         EL_Seconds = 59
                                                         EL_SecondsChanged = 1
                                                         EL_MinutesChanged = 1
                                                         EL_HoursChanged = 1
                                                         EL_DaysChanged = 1
                                                      ELSE                      ; Zero already reached, shouldn't get here
                                                         EL_ZERO = 1            ; set flag for 0 reached 
                                                      ENDIF
                                                  ENDIF
                                              ENDIF
                                            ENDIF
                                         ENDIF
                                    ; ENDIF
                                else                                     ' counting  up 
                                   ; if EL_ticks // T1PS = 0  THEN      ' if modulas of tips (4) = 0 
                                       if Internal_Cal = 1 then           ' if the internal calibration flag set - used with cro to check 10ms pulse 
                                         IF LATE.4 = 0 THEN           ' debug pin 
                                             LATE.4 = 1
                                          ELSE 
                                             LATE.4 = 0
                                          ENDIF   
                                       endif
                                        EL_100th = EL_100th + 1 
                                        EL_100thChanged = 1
                                        IF EL_100TH  = 100 THEN
                                            EL_100TH = 0
                                            EL_Seconds = EL_Seconds + 1      
                                            EL_SecondsChanged = 1
                                            IF EL_Seconds = 60 THEN
                                               EL_Seconds = 0
                                               EL_Minutes = EL_Minutes + 1
                                               EL_MinutesChanged = 1
                                            eNDIF
                                            IF EL_Hours_EN = 1 and EL_Minutes = 60 THEN
                                               EL_Minutes = 0
                                               EL_Hours = EL_Hours + 1
                                               EL_HoursChanged = 1
                                            ENDIF
                                            IF EL_Days_EN = 1 and EL_Hours = 24 THEN
                                               EL_Hours = 0 
                                               EL_Days = EL_Days + 1
                                               EL_DaysChanged = 1
                                            ENDIF
                                        eNDIF
                                   ; endif
                                ENDIF

                              Comment

                              Working...
                              X