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.
Bookmarks