BlinkyLED

The ultimate overkill Blinky Light program ... using Timer 1 Example 2:

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 TMR1_INT, _ToggleLED1, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM

T1CON = $31 ; Prescaler = 8, TMR1ON
@ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts

Main:
PAUSE 1
GOTO Main

'---[TMR1 - interrupt handler]--------------------------------------------------
ToggleLED1:
TOGGLE LED1
@ INT_RETURN

Code Size = 558 bytes

This program will blink an LED at a constant rate.

You can add anything to the Main program loop, and it will still continue to flash at the same rate.

Page last modified on February 07, 2018, at 07:11 PM