Melanie helped with some example code in this thread http://www.picbasic.co.uk/forum/showthread.php?t=3589
and I figure I'm still confused somewhere in the setup. I defines both "OldPorta" and "NewPorta" which I THINK was the way to start it but when I get the interupt it just defaults to the operation for Porta.5. The following program was supposed to do the following.
If pin Porta.5 is interupted an led would blink 4 times. Porta.4, 3 times, Porta.3, 2 times. Every time it is interupted it blinks 4 times no matter which pin. I can't seem to figure out, probibly from inexperience, what I'm doing wrong. If someone could help I'd appriciate it.
@ DEVICE PIC16F676,INTRC_OSC_NOCLKOUT,WDT_ON,PWRT_OFF,BOD_O FF,PROTECT_OFF,CPD_OFF,MCLR_OFF
ANSEL = 0 ' DISABLE THE ANALOG INPUT
CMCON = 7 ' DISABLE COMPARATOR ON PORTA
VRCON = 0 ' A/D Voltage reference disabled
TRISA = %00111110 ' SETS ALL PORTA PINS TO INPUT ' Set PORTAA to all input
WPUA = %00000110
SYMBOL LED = PORTA.0
I VAR WORD
OLDPORTA VAR WORD
NEWPORTA VAR WORD
INTCON = %10000000
IOCA = %00111000
OPTION_REG = %00001000
OUTPUT PORTA.0
LOW LED
PAUSE 1000
HIGH LED
GOTO BASE
MYINT:
NEWPORTA = PORTA
INTCON = %10000000
IF NEWPORTA.5 <> OLDPORTA.5 THEN
ILOOP:
I = I + 1
IF I = 5 THEN
resume BASE
ENDIF
LOW LED
PAUSE 1000
HIGH LED
PAUSE 1000
GOTO ILOOP
ENDIF
IF NEWPORTA.4 <> OLDPORTA.5 THEN
I = I + 1
IF I = 4 THEN
resume BASE
ENDIF
LOW LED
PAUSE 1000
HIGH LED
PAUSE 1000
GOTO ILOOP
ENDIF
IF NEWPORTA.3 <> OLDPORTA.5 THEN
I = I + 1
IF I = 3 THEN
resume BASE
ENDIF
LOW LED
PAUSE 1000
HIGH LED
PAUSE 1000
GOTO ILOOP
ENDIF
BASE:
OLDPORTA = PORTA
I = 0
ON INTERRUPT GOTO MYINT:
INTCON = %10001000
LOOP:
SLEEP 240
GOTO LOOP
Bookmarks