I have two codes which both of them works.
But i don't understand which is the difference with Interrupt and without Interrupt.
The operation both of them is the same
The first with Interrupt is :
Code:
' On Interrupt - Interrupts in BASIC
' Turn LED on-off. Interrupt on PORTB.0 (INTE) turns LED1 on
' Program waits 1 seconds and turns LED1 back off.
' 16F88
led var PORTA.2
led1 var PORTA.3
CMCON = 7
ANSEL = 0
On Interrupt goto myint ' Define interrupt handler
OPTION_REG = %00111111
INTCON = %10010000 ' Enable INTE interrupt
loop:
High LED
Pause 100
Low LED
Pause 100
Goto loop ' Do it forever
' Interrupt handler
Disable ' No interrupts past this point
myint:
High LED1 'If we get here, turn LED1 on
Pause 1000 ' Wait 1 seconds
Low LED1 ' If we get here, turn LED1 off
INTCON.1=0 ' Clear interrupt flag
Resume ' Return to main program
Enable
The second without Interrupt is :
Code:
' 16F88
led var PORTA.2
led1 var PORTA.3
CMCON = 7
ANSEL = 0
TRISB=%11111111
loop:
if PORTB.0=0 THEN GOSUB myint
High LED
Pause 100
Low LED
Pause 100
Goto loop 'Do it forever
myint:
High LED1 'If we get here, turn LED1 on
Pause 1000 'Wait 1 seconds
Low LED1 'If we get here, turn LED1 off
RETURN
Bookmarks