ME Labs, Inc.
719-520-5323
 
Home:
  Developer Resources:

Programming Clues
    Sample Programs
   
    PICBASIC PRO™
Compiler Manual
    PICBASIC™ Compiler
Manual
    Serin2/Serout2 Modes
    ASCII Character Set
    Number Conversion
    Floating Point
Routines
    PBP Debug Monitor
    Articles and Tutorials

Hardware Clues
    Parts / Vendor List
    PICPROTO™ Boards
    LAB-X1 Docs
    LAB-X2 Docs
    LAB-X20 Docs
    LAB-X3 Docs
    LAB-X4 Docs
    LAB-XUSB Docs
    LAB-XT Docs
     
 

ME Labs, Inc. | 1-719-520-5323 | Example Program - ONINT.pbp

PICBASIC PRO program to demonstrate use of On Interrupt Interrupts in BASIC. Turn LED on. Interrupt on PORTB.0 (INTE) turns LED off. Program waits .5 seconds and turns LED back on.
' Name        : ONINT.pbp
' Compiler    : PICBASIC PRO Compiler 2.6
' Assembler   : PM or MPASM
' Target PIC  : 12F, 16F, 18F
' Hardware    : Non specific
' Oscillator  : internal or external
' Keywords    : ON INTERRUPT
' Description : PICBASIC PRO program to demonstrate use of On Interrupt
' Interrupts in BASIC. Turn LED on.  Interrupt on PORTB.0 (INTE) turns LED off.
' Program waits .5 seconds and turns LED back on.
'

led Var PORTB.7

   OPTION_REG = $7f        ' Enable PORTB pullups

   On Interrupt Goto myint ' Define interrupt handler
   INTCON = $90            ' Enable INTE interrupt

mainloop:
   High led                ' Turn LED on
   Goto mainloop           ' Do it forever

' Interrupt handler
  Disable                  ' No interrupts past this point
myint:
   Low led                 ' If we get here, turn LED off
   Pause 500               ' Wait .5 seconds
   INTCON.1 = 0            ' Clear interrupt flag
   Resume                  ' Return to main program
   Enable

   End

           

Download the program file.