I have put an extra LED into the circuit to monitor whether the Analogue Interrupt is being triggered, this LEDstatus1 (analogue interrupt sub program) does not seem to toggle. This leads to believe that the issue maybe to do with the analogue input not being read.
If anybody can see any issues I would appreciate itCode:clear DEFINE OSC 8 'GP0 LED OUT 'GP1 AD1 FOR POT INPUT 'GP2 LED STATUS 'GP5 LED STATUS 1 'REGISTERS OPTION_REG = %11000000 INTCON = %11000000 PIE1 = %01000001 PIR1 = %00000000 OSCCON = %01110001 TRISIO = %00000001 ANSEL = %00100001 CCP1CON = %00000000 CMCON0 = %00000100 INCLUDE "DT_INTS-14.bas" ' Base Interrupt System INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts ;--------------------------------------------------------------------------- wsave VAR BYTE $20 SYSTEM ' location for W if in bank0 ;wsave VAR BYTE $70 SYSTEM ' alternate save location for W ' if using $70, comment wsave1-3 ' --- IF any of these three lines cause an error ?? ------------------------ ' Comment them out to fix the problem ---- ' -- Which variables are needed, depends on the Chip you are using -- wsave1 VAR BYTE $A0 SYSTEM ' location for W if in bank1 'wsave2 VAR BYTE $120 SYSTEM ' location for W if in bank2 'wsave3 VAR BYTE $1A0 SYSTEM ' location for W if in bank3 ' -------------------------------------------------------------------------- 'OUTPUT PINS LEDOut VAR GPIO.0 LEDStatus VAR GPIO.2 LEDStatus1 var GPIO.5 high ledstatus pause 500 low ledstatus pause 1000 high ledstatus pause 500 low ledstatus T1CON = %00110001 'VARIABLES LENGTH VAR WORD PauseA var byte PASS var byte ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler TMR1_INT, _StateChange, PBP, yes INT_Handler AD_INT, _PulseLength, PBP, yes endm INT_CREATE ; Creates the interrupt processor ENDASM @ INT_ENABLE TMR1_INT @ INT_ENABLE AD_INT ADCON0 = %00000111 'MAIN PROGRAM MAIN: pausea = 0 WHILE PauseA <= 10 PAUSEA = PAUSEA + 1 pause 1 wend toggle ledstatus GOTO MAIN 'SUB PROGRAMS PulseLength: LENGTH.highbyte = ADRESH 'SET UP THE TIMER SET UP VARIABLES LENGTH.lowbyte = ADRESL ADCON0 = %00000111 toggle ledstatus1 @ INT_RETURN ;RETURN StateChange: if pass = 10 then TOGGLE lEDOUT pass = 0 else pass = pass + 1 endif TMR1H = LENGTH.highbyte 'Transfer the timer variables to the timer register TMR1L = LENGTH.lowbyte T1CON = %00010101 @ INT_RETURN ;RETURN END
Thank you




Bookmarks