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