I am not able to trigger the interrupt, can Somebody enlight me on what is wrong in the above code?Code:'------------------------------------------------------------------------------- '| Name : Light_12F683.BAS | '| Author : | '| Notice : Copyright (c) 2010 All Rights Reserved | '| : | '| Date : 18/12/2014 | '| Version : 1.0 | '| Notes : Pic 12F683 light controller | '------------------------------------------------------------------------------- ' P12F683 (pin usage) ' ' pin # 1 = Vdd (+ 5 Volts) ' pin # 2 = GPIO.5 (Digital output [Led]) ' pin # 3 = GPIO.4 (N/U) ' pin # 4 = GPIO.3 (MCLR) ' pin # 5 = GPIO.2 (Digital output) ' pin # 6 = GPIO.1 (input chan B) ' pin # 7 = GPIO.0 (input chan A) ' pin # 8 = Vss (ground) ' '------------------------------------------------------------------------------- ;----[12F683 Hardware Configuration]-------------------------------------------- #IF __PROCESSOR__ = "12F683" #DEFINE MCU_FOUND 1 #CONFIG cfg = _INTOSCIO ; INTOSCIO oscillator: I/O function cfg&= _WDT_OFF ; WDT disabled cfg&= _PWRTE_OFF ; PWRT disabled cfg&= _MCLRE_ON ; MCLR pin function is MCLR cfg&= _CP_OFF ; Program memory code protection is disabled cfg&= _CPD_OFF ; Data memory code protection is disabled cfg&= _BOD_ON ; BOR enabled cfg&= _IESO_ON ; Internal External Switchover mode is enabled cfg&= _FCMEN_ON ; Fail-Safe Clock Monitor is enabled __CONFIG cfg #ENDCONFIG #ENDIF ;----[Verify Configs have been specified for Selected Processor]---------------- ; Note: Only include this routine once, after all #CONFIG blocks #IFNDEF MCU_FOUND #ERROR "No CONFIGs found for [" + __PROCESSOR__ +"]" #ENDIF ' '------------------------------------------------------------------------------- ' ' include "ALLDIGITAL.pbp" DEFINE SHOWDIGITAL 1 INCLUDE "DT_INTS-14.bas" ; Base Interrupt System INCLUDE "ReEnterPBP.bas" ; Include if using PBP interrupts DEFINE OSC 8 ' Oscillator frequency ' ' '------------------------------------------------------------------------------- ' OSCCON = %01110111 ' oscillator setting internal 8 MHz ' ANSEL = %00100000 ' set all digital ' CMCON0 = 7 ' comparator off OPTION_REG = %11100000 ' weak pullup enabled GPIO = %00000000 ' set all pins to zero ' ' TRISIO = %00001011 ' configure direction 1=input 0=output ' ' '------------------------------------------------------------------------------- ' ' Led var GPIO.5 ' Alias for GPIO.5 pin # 2 A_opto var GPIO.0 ' Alias for GPIO.0 pin # 7 B_Opto var GPIO.1 ' Alias for GPIO.1 pin # 6 Luce var GPIO.2 ' Alias for GPIO.2 pin # 5 ' '------------------------------------------------------------------------------- ' wsave VAR BYTE $20 SYSTEM wsave1 var byte $A0 SYSTEM A0 var byte B0 var byte C0 var byte F0 var byte Flag_Count var byte Flag_In var bit Flag_Out var bit ' ' '------------------------------------------------------------------------------- ' Flag_Count = 0 Flag_Out = 0 Flag_In = 0 A0 = 0 B0 = 0 F0 = 0 ' ' asm INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler GPC_INT, _Opto_Read, PBP, yes endm INT_CREATE ; Creates the interrupt processor ENDASM @ INT_ENABLE GPC_INT ' '------------------------------------------------------------------------------- ' goto Main ' '---------------------------------- Ini ISR ------------------------------------ ' Opto_Read: A0 = GPIO & %00000011 If A0 = 1 Then Flag_In = 1 If A0 = 3 and Flag_In = 1 Then Flag_Count = Flag_Count + 1 If A0 = 2 Then Flag_Out = 1 If A0 = 3 and Flag_Out = 1 Then Flag_Count = Flag_Count - 1 @ INT_RETURN ' '------------------------------------------------------------------------------- ' Main: If Flag_In = 1 and Flag_Count > 0 Then Luce = 1 Flag_In = 0 endif If Flag_Count > 100 then Flag_Count = 0 ' If Flag_Out = 1 and Flag_Count = 0 Then Luce = 0 Flag_Out = 0 endif ' Pause 1 F0 = F0 + 1 If F0 > 200 then Led = !Led F0 = 0 endif goto Main ' goes back to main loop ' '------------------------------------------------------------------------------- ' end ' end program
Thank you
Al.




Bookmarks