DT CMP Interrupt Problem


Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Aug 2008
    Posts
    66

    Question DT CMP Interrupt Problem

    I'm using PIC16F877, and have 2 analog inputs IN1 and IN2. I want to generate interrupt if voltage IN1 > IN2. Do I keep reading the AD register and compare it with IN2 voltage during each CMP interrupt? Or is there a more efficient way to implement this?


    Code:
    define OSC 20
    INCLUDE "DT_INTS-14.bas"     ' Base Interrupt System
    INCLUDE "ReEnterPBP.bas"     ' Include if using PBP interrupts
    
    ASM
    INT_LIST  macro    ; IntSource,  Label,  Type, ResetFlag?
           INT_Handler    CMP_INT,  _Int_Cmp,   PBP,  yes        
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    @    INT_DISABLE   CMP_INT     ;Comparator int
    
    ADCON1= %00000000      'enable all analog inputs
    LED var PORTB.7
    
    loop:
    'start ad here
    
    'end ad 
    pause 50
    goto loop
    
    '---[CMP - interrupt handler]----------------------------------------------
    Int_Cmp:
    toggle LED 
    
    'read and store ad result here
    
    @ INT_RETURN
    I haven't finish the code above, but am getting a compilation error in Microcode "symbol not previously defined [CMIF]". PLease help.
    Last edited by Pic2008; - 29th November 2008 at 15:12.

Similar Threads

  1. Problem with Interrupt on PIC18F4620 PORTB
    By rookie in forum Off Topic
    Replies: 1
    Last Post: - 22nd March 2007, 01:34
  2. Replies: 1
    Last Post: - 2nd November 2006, 23:24
  3. Interrupt Problem
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th November 2005, 20:58
  4. Interrupt stack overflow problem with Resume {label}
    By Yuantu Huang in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 3rd May 2005, 01:17
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

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