PBP array in ASM statements


Results 1 to 20 of 20

Threaded View

  1. #15
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: PBP array in ASM statements

    Same with DT_INT...
    Code:
    INCLUDE "DT_INTS-18.bas"     ; Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas"     ; Include if using PBP interrupts
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    TMR1_INT,  _RTC,   PBP,  yes
            INT_Handler    TMR3_INT,  _CNT,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    
    DEFINE        OSC 4         ' We're using a 10MHz oscillator
    'Define        INTHAND myint    ' Define interrupt handler
    DEFINE HSER_BAUD 2400
            OSCCON=%01010110
            OSCCON2.2=0
            OSCTUNE.7=1
            OSCTUNE.6=1
            REFCON0=0
            REFCON1=0
            ADCON1=0
            ADCON2=0
            ANSEL =0           
            ANSELH=0
            CM1CON0=0
            CM2CON0=0
            SRCON0=0
            SRCON1=0
            WPUA=0
            WPUB=0
            WDTCON=0   
            SLRCON=0           
            RCON.7=0
            RCON.6=0   
            UCON=0  
            IOCA=0
            IOCB=0
            T0CON=0
            T1CON=%00001111  
            T2CON=0
            T3CON=%00000110
            INTCON=192  
            INTCON2=0  
            INTCON3=0 
            PIR1=0
            PIR2=0
            PIE1=1
            PIE2=2
            IPR1=0
            IPR2=0
            porta=0
            portb=0
            portc=0
            trisa=255
            trisb=255
            trisc=255
    'RTC_________________________
    Seconds        VAR BYTE bankA  ' variables within myint must be in bank 0.
    Minutes        VAR Byte bankA       ' Elapsed minutes
    Hours          var byte bankA
    Day            var byte bankA     
    Month          var byte bankA
    Year           var byte bankA
    Ticks          var byte bankA
    DMonth         var byte bankA
    'IO________________
    SYMBOL Ul1  =PORTB.5
    SYMBOL Ul2  =PORTB.6
    SYMBOL Pull =PORTC.4
    SYMBOL UWp  =PORTC.3
    'TRIS______________
    INPUT  Ul1
    INPUT  Ul2
    OUTPUT Pull
    INPUT  uwp
    'Brojaci___________
    Brojac  VAR LONG[3] bankA
    PomBroj VAR WORD[2] bankA
    Mtp1    VAR BYTE[2] bankA
    Mtp2    VAR BYTE[2] bankA
    Add     VAR BYTE[2] bankA
    Xn      VAR BYTE    bankA
    Xs      VAR BYTE    bankA
    
    Wp      VAR BIT     bankA
    Trf     VAR BIT     bankA
    Smpl    VAR BIT     bankA
    
    
    
        year=0
        month=0
        day=0
        hours = 4
        minutes = 0       ' Pre Set time here then add seconds to clock using button
        seconds = 0
        ticks=0
        smpl=0  
        PomBroj[0]=0
        PomBroj[1]=0
        Brojac[0]=0
        Brojac[1]=0
        mtp1[0]=1
        mtp1[1]=1
        mtp2[0]=1
        mtp2[1]=1
        add[0]=1
        add[1]=1
        Trf=0
    @    INT_ENABLE  TMR3_INT     
    @    INT_ENABLE  TMR1_INT 
    GoTo mainloop          ' jump over the interrupt handler and sub
                           
    RTC:
       TMR1H=252
    @  INCF _Ticks,F           
       if ticks=32 then 
    @     INCF _Seconds,F  
    @     CLRF _Ticks
          if seconds > 59 then
    @        CLRF _Seconds   
    @        INCF _Minutes,F
             if minutes > 59 then
    @          CLRF _Minutes
    @          INCF _Hours,F
               if hours > 23 then 
    @             CLRF _Hours
    @             INCF _Day,F
                  If month=2 then
                     If year//4<>0 then
                        DMonth=29
                     else
                        DMonth=28
                     endif
                  else
                  Dmonth=30+month.0 
                  endif   
                  If day>Dmonth then
    @                CLRF _Day
    @                INCF _Month,F
                     If month>12 then
    @                   CLRF _Month
    @                   INCF _Year,F
                        if year>99 then year=0
                     endif
                  endif
               endif
             endif
        endif 
       endif
       Pull=1
       TMR3H=255
       IF Smpl=1 then
          TMR3L=207
       else
          TMR3L=240
       endif
       T3CON=%00000111
    @ INT_RETURN
    
    CNT:
       T3CON=%00000110
       Wp= Wp & uwp
       Xn.0=ul1
       Xn.1=ul2
       Pull=0
        
       IF (Xn.0<Xs.0 AND Trf=0) OR  (Xn.0<Xs.0 AND Xn.1=1 AND Trf=1) THEN
    @     INCF _PomBroj,F 'PomBroj[0] = PomBroj[0] + 1 
          IF PomBroj[0] = Mtp2[0] OR (PomBroj=256 AND Mtp2[0]=0)THEN
           Brojac[0]=Brojac[0] + Add[0]
    @      CLRF _PomBroj'PomBroj[0]=0
          ENDIF
       ENDIF
        
       IF (Xn.1<Xs.1 AND Trf=0) OR (Xn.0<Xs.0 AND Trf=1 AND Xn.1=0) THEN
          PomBroj[1] = PomBroj[1] + 1    '  @     INCF _PomBroj+1,F '
          IF PomBroj[1] = Mtp2[1] OR (PomBroj[1]=256 AND Mtp2[1]=0)THEN
           Brojac[1]=Brojac[1]+Add[1]
    @      CLRF _PomBroj+1         'PomBroj[1]=0  
          ENDIF
       ENDIF
       Xs=Xn
    @ INT_RETURN
    
    mainloop:
    if ticks = 0 then
     trisb.7=0      
      ' 2 portb.7,84,
     hserout ["B1: ",dec9 brojac[0]," B2: ",dec9 brojac[1],13,10]'["Time: ",DEC hours, ":", DEC2 minutes, ":", DEC2 seconds,13,10]
    
    endif
    
    GoTo mainloop       ' Repeat main loop
    
    End
    Edit:
    With the DT_INT code is twice bigger than it was. Maybe I could try to get rid of arrays.
    But it complicates the rest of my code... But on the other hand we will slightly extend the battery life...
    Last edited by pedja089; - 29th May 2011 at 00:04.

Members who have read this thread : 0

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