Rob,
Glad it worked for you.
I'm not sure if you want/need to stay in the ISR as I don't know your final objective.
I would suggest using a flag to determine the state of the IOC.3 interrupt coming from your button.
Then in the ISR change the state of the flag each time the interrupt occurs and then get out of the ISR.
You can then setup a subroutine for what you wanted to accomplish in the ISR.
Finally in your main loop check the state of the flag and gosub to the new subroutine.
Here is a working example. Expanded on what I posted last time.
Code:'PIC 12F683 #CONFIG __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF #ENDCONFIG 'DEFINE OCS 4 '4mhz ocsillator DEFINE OSC 4 '4mhz ocsillator ANSEL = 0 'all I/O digital CMCON0 = 7 'comparator off LED VAR GPIO.0 'LED pin 7 LED2 VAR GPIO.1 'LED2 pin 6 loop1 var word ' Loop 1 Counter (word for 0 to 65535 increments) loop2 var byte ' Loop 2 Counter (byte used for 0 to 255 increments) ModeFlag var bit ' Bit to determine what state of IOC.3 is '*****Initlaze Vars***** loop1 = 0 loop2 = 0 ModeFlag = 0 '*********************** ON INTERRUPT GOTO mode1 'interrupt handler is mode1 INTCON = %10001000 'enable GIE and GPIE; clear GPIF IOC = %00001000 ' enable IOC3 (GPIO3 Interrupt on change) ENABLE main: do for loop1 = 1 to 500 HIGH LED 'led on 'PAUSE 500 'delay 0.5 second pause 1 '1 ms if ModeFlag = 1 then gosub moderoutine endif next loop1 for loop1 = 1 to 500 LOW LED 'led off 'PAUSE 500 'delay 0.5 second pause 1 '1 ms if ModeFlag = 1 then gosub moderoutine endif next loop1 'GOTO main 'repeat loop moderoutine: do while ModeFlag = 1 high LED2 'LED2 On for loop2 = 0 to 50 pause 1 '1ms next loop2 low LED2 'LED2 Off for loop2 = 0 to 50 pause 1 '1ms next loop2 loop return DISABLE 'disable interrupts in handler mode1: if INTCON.0 = 1 then 'one of the GPIO<5:0> pins changed state (must be cleared in software) 'HIGH LED2 'led2 on 'PAUSE 50 'LOW led2 'led2 off 'PAUSE 50 'Set the ModeFlag ModeFlag = ~ ModeFlag endif INTCON = %10001000 'enable GIE and GPIE; clear GPIF RESUME 'return to where left off ENABLE 'enable interrupts end 'got here by mistake




Bookmarks