PDA

View Full Version : 16F676 Interupt



BGreen
- 5th March 2006, 13:16
I'm switching from a 12F629 to a 16F676 to get more pins and trying to work out the differences in the pics. The following is supposed to use a falling edge Port Change Interupt on Pin 2. The program Blinks an LED at power up and is supposed to blink it 5 times at interupt. It blinks at power up but does not interupt. I had all of it worked out for the 629 and am sure there is something small I'm missing, but I can't seem to find it. Any help would be appriciated.

@ 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
WPUA = %00110110
SYMBOL TRIG = PORTA.5
SYMBOL LED = PORTA.0
I VAR WORD
INTCON = %10000000
IOCA = %00100000
OPTION_REG = %00001000
OUTPUT PORTA.0
LOW LED
PAUSE 1000
HIGH LED
GOTO BASE
MYINT:
INTCON = %10000000
ILOOP:
I = I + 1
IF I = 5 THEN
GOTO BASE
ENDIF
GOTO ILOOP
LOW LED
PAUSE 1000
IF TRIG = 0 THEN
ENDIF
GOTO ILOOP
BASE:
I = 0
ON INTERRUPT GOTO MYINT:
INTCON = %10001000
LOOP:
SLEEP 240
GOTO LOOP

Archilochus
- 5th March 2006, 19:50
Hi Butch,
Check out this bit...

ILOOP:
I = I + 1
IF I = 5 THEN
GOTO BASE
ENDIF
GOTO ILOOP


When interrupted, that will just increment 'I', jump back to 'ILOOP, then go back to 'BASE' when 'I'=5, never blinking the LED.

BTW - the 'MYINT' should terminate with a 'RESUME' - don't know what will happen the way it is in your code.

Arch

BGreen
- 5th March 2006, 20:56
Thank you Arch. I looked at that so many times its nuts and never saw it. Figured another set of eyes would pick something up easily. Works like a charm now!