Code:
LED1 VAR PORTD.0
LED2 VAR PORTD.1
INCLUDE "DT_INTS-14.bas" ' Base Interrupt System
INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts
INCLUDE "Elapsed_INT.bas" ' Elapsed Timer Routines
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler INT_INT, _ToggleLED1, PBP, yes
INT_Handler TMR0_INT, _ToggleLED2, PBP, yes
INT_Handler TMR1_INT, _ClockCount, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
OPTION_REG = OPTION_REG & $80 | 1 ; Set TMR0 Prescaler to 256, leave RBPU alone
@ INT_ENABLE INT_INT ; enable external (INT) interrupts
@ INT_ENABLE TMR0_INT ; enable Timer 0 interrupts
@ INT_ENABLE TMR1_INT ; Enable Timer 1 Interrupts
GOSUB ResetTime ' Reset Time to 0d-00:00:00.00
GOSUB StartTimer ' Start the Elapsed Timer
Main:
IF SecondsChanged = 1 THEN
SecondsChanged = 0
IF Hours>9 THEN
SEROUT PORTB.1,6,[254,128,#Hours,58]
pause 300
ELSE
SEROUT PORTB.1,6,[254,128,48,#Hours,58]
pause 30
ENDIF
IF Minutes>9 THEN
SEROUT PORTB.1,6,[254,131,#Minutes,58]
pause 300
ELSE
SEROUT PORTB.1,6,[254,131,48,#Minutes,58]
pause 300
ENDIF
IF Seconds>9 THEN
SEROUT PORTB.1,6,[254,134,#Seconds]
pause 300
ELSE
SEROUT PORTB.1,6,[254,134,48,#Seconds]
pause 300
ENDIF
GOTO Main
'---[INT - interrupt handler]---------------------------------------------------
ToggleLED1:
TOGGLE LED1
@ INT_RETURN
'---[TMR0 - interrupt handler]-------------------------------(Blinky Light)------
T0Count VAR WORD
ToggleLED2:
T0Count = T0Count + 1
IF T0Count = 512 THEN T0Count = 0 : TOGGLE LED2
@ INT_RETURN
Bookmarks