PDA

View Full Version : always go to interrupt



savnik
- 25th March 2007, 19:24
i have a problem with below code.
always go to interrupt.Why;
i use pic16f88
i have pull-ups resistors to rb4-rb7




INTCON = %10001000 ' %10001000 enable interrupts on RB4 through RB7

SW1 var PORTB.4
SW2 var PORTB.5
SW3 var PORTB.6
SW4 var PORTB.7

LED1 var PORTA.0
LED2 var PORTA.1

On Interrupt goto inter ' Define interrupt handler

TRISA=%11110000 'PA3-PA0=output
TRISB=%11110000 'PB7-PB4=input, PB3-PB0=output
PORTA=0 'Turn off all LEDs

Loop:
High PORTA.0
Pause 500
Low PORTA.0
Pause 500
goto Loop

Disable ' No interrupts past this point
inter:

'*** Blinking routine ***

High PORTA.0
Pause 500
Low PORTA.0
Pause 500
High PORTA.1
Pause 500
Low PORTA.1
Pause 500

INTCON.0=0 ' Clear interrupt flag
Resume ' Return to main program
Enable

End

skimask
- 25th March 2007, 19:32
Section 5.2 of the 16F88 datasheet, mainly the 3rd paragraph

sougata
- 26th March 2007, 03:31
Hi,


INTCON.0=0 ' Clear interrupt flag


You need to use INTCON = $80 to clear interrupt flags. Also the portb mismatched condition is cleared when you read it.