First time using comparators DT interrupts


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    May 2008
    Location
    Italy
    Posts
    825

    Default First time using comparators DT interrupts

    I am trying some experiments using both comparators on pic 16F88 (mind you my first time), where I need interrupts. It seems I am unable to compile due to some errore with the interrupt.

    Below the code and the errors at the end of compilation (same thing with PBP 2.47 and PBP3)

    Code:
    INCLUDE "DT_INTS-14.bas"        ; Base Interrupt System
    'INCLUDE "ReEnterPBP.bas"        ; Include if using PBP interrupts
    
    DEFINE OSC 20
    
    CMCON = %00000100
    TrisA = %00001111
    TrisB = %00000000
    PortB = 0
    
    Led                 var PortB.3
    Flag                var bit
    wsave               VAR BYTE    $70     SYSTEM  ' alternate save location for W 
    Q_New               var Byte
    Q_Old               var byte
    Q_Count             var word
    
    
    ' Set variable value @ startup  
       
       Flag = 0          
      Q_New = 0
      Q_Old = 0
    Q_Count = 0
    
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, Resetflag?       
            INT_Handler    CMP1_INT  _Encoder,   ASM,  yes
            INT_Handler    CMP2_INT  _Encoder,   ASM,  yes
        endm
        INT_CREATE                   ; Creates the interrupt processor
    ENDASM
    
    
    @ INT_ENABLE CMP1_INT            ; enable comp1 (INT) interrupts
    @ INT_ENABLE CMP2_INT            ; enable comp2 (INT) interrupts
    
    
    Goto Main_Loop
    
    
    Encoder:
    
       Q_New = CMCON.7 + CMCON.7 + CMCON.6
    
    if Q_Old = 0 then
    if Q_New = 2 then Minus_Count
    if Q_New = 1 then Plus_Count
    endif
    
    if Q_Old = 1 then
    if Q_New = 0 then Minus_Count
    if Q_New = 3 then Plus_Count
    endif
    
    if Q_Old = 3 then
    if Q_New = 1 then Minus_Count
    if Q_New = 2 then Plus_Count
    endif
    
    if Q_Old = 2 then
    if Q_New = 3 then Minus_Count
    if Q_New = 0 then Plus_Count
    endif
    
    goto Q_Skip
    
    Minus_Count:
     Q_Count = Q_Count - 1
    
    goto Q_Skip
    
    Plus_Count:
     Q_Count = Q_Count + 1
    
    Q_Skip:
       Q_Old = Q_New
     
         Led = !Led 
    
    @ INT_RETURN
    
    Main_Loop:   
    
    goto Main_Loop
    
    end
    Surely is something due to my inexperience with comparators, so need some help. Any suggestion is welcome.

    Cheers

    Al.
    Attached Images Attached Images  
    All progress began with an idea

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


    Did you find this post helpful? Yes | No

    Default Re: First time using comparators DT interrupts

    Hi Al,

    The 16F88 doesn't have separate interrupt flags for the 2 comparators.
    Both comparators use the same flag.

    So with DT_INTS, use the single CMP_INT handler.
    DT

  3. #3
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: First time using comparators DT interrupts

    Thank you Darrel for the quick answer.

    Cheers

    Al.
    All progress began with an idea

  4. #4
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: First time using comparators DT interrupts

    Used CMP_INT without any luck. Stil getting two asm errors :

    553 - missing argument
    472 - "INT_HANDLER" interrupt flag not found.

    Any suggestion?

    Cheers

    Al.
    All progress began with an idea

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


    Did you find this post helpful? Yes | No

    Default Re: First time using comparators DT interrupts

    Al,

    I think you just need a comma in your INT_Handler line.
    Code:
            INT_Handler    CMP_INT,  _Encoder,   ASM,  yes
    DT

  6. #6
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: First time using comparators DT interrupts

    Yes Darrel, it was just the comma missing. Thank you again.

    Cheers

    Al.
    All progress began with an idea

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