mel4853
- 1st June 2013, 15:59
The interrupt works perfect but if I hold the button down for a little while then let up the interrupt will hang, but if you just wait it will come out of it and start working again.Using a 16F688.
define OSC 4
INCLUDE "DT_INTS-14.bas" ' Base Interrupt System
include "ReEnterPBP.bas"
@ ERRORLEVEL -306 ; turn off crossing page boundary message
'-----------------------REGISTERS----------------------------------------
TRISA=%111000 ' RA3,RA4,RA5 inputs
ANSEL=%00000000 ' All digital
TRISC=%00000011 ' RC0,RC1, input
CMCON0=%111 ' Shut off comparators
;OPTION_REG.7=0
WPUA=%111000 ' Weak Pull Ups Enabled
INTCON.7=1 'Enable Global Interrupts
IOCA=%110000 'Enable IOC
'Variables---------------------------------------------------------------------
Forward var PORTC.0
ForwardBut var PORTA.4
Reversed var PORTC.1
ReverseBut var PORTA.5
Led var PORTC.2
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler RAC_INT, _Motor, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
INT_ENABLE RAC_INT ; enable ioc
ENDASM
Main:
high led
pause 200
low led
pause 200
goto main
Motor:
if ForwardBut=0 then
high forward
pause 100
do while ForwardBut=0
loop
low forward
endif
if ReverseBut=0 then
high reversed
pause 100
do while ReverseBut=0
loop
low reversed
endif
@ INT_RETURN
define OSC 4
INCLUDE "DT_INTS-14.bas" ' Base Interrupt System
include "ReEnterPBP.bas"
@ ERRORLEVEL -306 ; turn off crossing page boundary message
'-----------------------REGISTERS----------------------------------------
TRISA=%111000 ' RA3,RA4,RA5 inputs
ANSEL=%00000000 ' All digital
TRISC=%00000011 ' RC0,RC1, input
CMCON0=%111 ' Shut off comparators
;OPTION_REG.7=0
WPUA=%111000 ' Weak Pull Ups Enabled
INTCON.7=1 'Enable Global Interrupts
IOCA=%110000 'Enable IOC
'Variables---------------------------------------------------------------------
Forward var PORTC.0
ForwardBut var PORTA.4
Reversed var PORTC.1
ReverseBut var PORTA.5
Led var PORTC.2
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler RAC_INT, _Motor, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
INT_ENABLE RAC_INT ; enable ioc
ENDASM
Main:
high led
pause 200
low led
pause 200
goto main
Motor:
if ForwardBut=0 then
high forward
pause 100
do while ForwardBut=0
loop
low forward
endif
if ReverseBut=0 then
high reversed
pause 100
do while ReverseBut=0
loop
low reversed
endif
@ INT_RETURN