Toggle LED Example

Here's a simple example of toggling an LED using the external interrupt (INT0). Example 1:

LED1 VAR PORTB.1

INCLUDE "DT_INTS-18.bas" ; Base Interrupt System
INCLUDE "ReEnterPBP-18.bas" ; Include if using PBP interrupts

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
 Code Size = 552 bytes

This program will simply toggle an LED in response to the external INT0 interrupt.

This example is almost exactly the same as the 14-bit version. The only difference being the -18 in the include file names.

The INT_INT source name was kept for compatibility, but it can also be INT0_INT, or any of the INT0 thru INT3 sources.

Page last modified on March 02, 2018, at 04:26 AM