Charles Linquis
- 10th January 2006, 20:36
I'm trying to get a timer interrupt to work, but the code below just doesn't run.
Can someone please tell me what I'm doing wrong? It seems like the ISR isn't getting called.
__________________________________________________ ____________
DEFINE OSC 4
DEFINE INTHAND TMRint
ADCON1 = 7
RCSTA = $90
TXSTA = $24
SPBRG = 25
wsave VAR BYTE bankA system
ssave VAR BYTE bankA system
fsave VAR WORD bankA system '
ASM_Seconds VAR BYTE bankA
T0CON = %10000101
Seconds VAR BYTE
OldSeconds VAR BYTE
OldSeconds = 0
ASM_Seconds = 0
GoTo START
Asm
TMRint
movwf wsave
swapf STATUS, W
clrf STATUS
movwf ssave
movf Low FSR0, W
movwf fsave
movf High FSR0, W
movwf fsave+1
; Do the real work here
;------------------------------------------------------------------------------
incf _ASM_Seconds,1
clrf TMR0IF
;----------------------------------------------------------------------------
movf fsave, W
movwf Low FSR0
movf fsave+1, W
movwf High FSR0
swapf ssave, W
movwf STATUS
swapf wsave, F
swapf wsave, W
retfie
EndAsm
START:
INTCON = %11100000 ' Enable TIMR0 interrupts
MAINLOOP:
GoSub GetSecs
IF Seconds <> OldSeconds THEN
OldSeconds = Seconds
HSEROUT [#Seconds," "]
EnDIF
GoTo MAINLOOP
GetSecs:
INTCON.7 = 0 ' Shut off interrupts when reading register
Seconds = ASM_Seconds
INTCON.7 = 1
Return
End
Can someone please tell me what I'm doing wrong? It seems like the ISR isn't getting called.
__________________________________________________ ____________
DEFINE OSC 4
DEFINE INTHAND TMRint
ADCON1 = 7
RCSTA = $90
TXSTA = $24
SPBRG = 25
wsave VAR BYTE bankA system
ssave VAR BYTE bankA system
fsave VAR WORD bankA system '
ASM_Seconds VAR BYTE bankA
T0CON = %10000101
Seconds VAR BYTE
OldSeconds VAR BYTE
OldSeconds = 0
ASM_Seconds = 0
GoTo START
Asm
TMRint
movwf wsave
swapf STATUS, W
clrf STATUS
movwf ssave
movf Low FSR0, W
movwf fsave
movf High FSR0, W
movwf fsave+1
; Do the real work here
;------------------------------------------------------------------------------
incf _ASM_Seconds,1
clrf TMR0IF
;----------------------------------------------------------------------------
movf fsave, W
movwf Low FSR0
movf fsave+1, W
movwf High FSR0
swapf ssave, W
movwf STATUS
swapf wsave, F
swapf wsave, W
retfie
EndAsm
START:
INTCON = %11100000 ' Enable TIMR0 interrupts
MAINLOOP:
GoSub GetSecs
IF Seconds <> OldSeconds THEN
OldSeconds = Seconds
HSEROUT [#Seconds," "]
EnDIF
GoTo MAINLOOP
GetSecs:
INTCON.7 = 0 ' Shut off interrupts when reading register
Seconds = ASM_Seconds
INTCON.7 = 1
Return
End