Device 16F84A
XTAL = 4.0
Declare Lcd_DTPin PortB.4
Declare Lcd_ENPin Portb.3
Declare Lcd_RSPin Portb.2
Symbol T0IF = INTCON.2 ' TMR0 Overflow Interrupt Flag
Symbol T0IE = INTCON.5 ' TMR0 Overflow Interrupt Enable
Symbol GIE = INTCON.7 ' Global Interrupt Enable
Symbol PS0 = OPTION_REG.0 ' Prescaler Rate Select
Symbol PS1 = OPTION_REG.1 ' Prescaler Rate Select
Symbol PS2 = OPTION_REG.2 ' Prescaler Rate Select
Symbol PSA = OPTION_REG.3 ' Prescaler Assignment
Symbol T0CS = OPTION_REG.5
DIM MS AS WORD
DIM SECOND AS BYTE
DIM MINUTE AS BYTE
DIM HOUR AS BYTE
PS0 = 1
PS1 = 0
PS2 = 0
PSA = 0
T0CS = 0 'set the clock source for internal oscillator
T0IF = 0 'clear the interrupt flag
T0IE = 1 'enable tmr0 interrupt
GIE = 1 'enable Global interrupts
TMR0 = 6
On Interrupt goto InterruptServiceRoutine
GoTo Main 'start of program, jumps straight to main
Disable 'disable interrupts
InterruptServiceRoutine:
T0IF = 0 'clear the interrupt flag
TMR0 = 6
INC MS
IF MS >= 999 THEN
MS = 0
INC SECOND
IF SECOND >= 59 THEN
SECOND = 0
INC MINUTE
IF MINUTE >= 59 THEN
MINUTE = 0
INC HOUR
ENDIF
ENDIF
ENDIF
Resume 'return back to where the main code was running
'before the interrupt
Enable 're enanble interupts
Main:
Print at 1,1, DEC HOUR," ",DEC MINUTE," ", DEC SECOND," ",DEC MS
GoTo Main