INT_INT -- INT External Interrupt
Used for external edge triggered interrupts such as RB0.
Uses INTCON,INTF, INTE Registers and Control Bits.
DT's Interrupts MUST be used with PicBasic Pro and MPASM.
The following block of instructions will establish the interrupt used and the PBP label (your ISR) to jump to once interrupt occurs. Remember; all PBP labels or variables used inside ASM code blocks must be preceded by the underscore,( _ToggleLED1). All instruction to the interrupt processor should be in ASM and preceded by the @ symbol and to the far left column of the editor if not included in other ASM code blocks.
Example:
@ INT_DISABLE INT_INT
ASM
INT_LIST macro ;IntSource Label, Type, ResetFlag? INT_Handler INT_INT _ToggleLED1 PBP Yes endm INT_CREAT ; Creates the interrupt processor INT_ENABLE INT_INT ;enables external (INT) interrupts
ENDASM
Command functions:
INT_CREATE ;Creates the interrupt processor
INT_ENABLE INT_INT – to enable INT interrupt after handler is created.
INT_DISABLE INT_INT – disable INT interrupt.
INT_CLEAR INT_INT -- clear flags
INT_RETURN -- To restore and return to the program where interrupt was made.
Check your Datasheet for IOCB or other registers that need to be addressed before implementing DT_INT's.
Rising Edge: OPTION_REG.6 = 1
Falling Edge: OPTION_REG.6 = 0
Here's a simple example of toggling an LED using the external interrupt (INT).
INCLUDE "DT_INTS-14.bas" ; Base Interrupt System INCLUDE "ReEnterPBP.bas" ; Include if using PBP interrupts LED1 VAR PORTB.1 ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler INT_INT, _ToggleLED1, PBP, yes endm INT_CREATE ; Creates the interrupt processor ENDASM @ INT_ENABLE INT_INT ; enable external (INT) interrupts Main: PAUSE 1 GOTO Main '---[INT - interrupt handler]--------------------------------------------------- ToggleLED1: TOGGLE LED1 @ INT_RETURN
Rising Edge: OPTION_REG.6 = 1
By default, the INT input will generate an interrupt on the Rising edge of the signal.
Using the circuit shown to the right, the LED will toggle on and off with each "Press" of the pushbutton (S1).
The INT input can also be configured to interrupt on the Falling edge by changing the INTEDG bit. (OPTION_REG.6)
INTEDG: Interrupt Edge Select bit 1 = Interrupt on rising edge of INT pin 0 = Interrupt on falling edge of INT pin
If you use this circuit with the Falling edge selected, then the LED will toggle on each button "Release".
Falling Edge: OPTION_REG.6 = 0
Usually it's not a good idea to allow the power supply voltage to leave the PC board. So, this circuit is preferred if using pushbuttons.
With INTEDG = 0, the LED will toggle with each button "Press". Or, with INTEDG = 1, it will toggle with each "Release"
<< | 14-bit sources | RAC_INT >>