PDA

View Full Version : Another interrupt question



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

Dave
- 10th January 2006, 22:36
Charles Linquis,I never see you setting the TMR0 value which means you are allowing it to overflow every 4.194 seconds. (1/4000000)x4x64x65536). This is assuming your TMR0 is a 16 bit timer.

Dave Purola,
N8NTA

Charles Linquis
- 11th January 2006, 01:59
I realize that I have to jam the timer with a value, I'll calculate that value when I get things running. The problem is - the ISR NEVER seems to get called.

Bruce
- 11th January 2006, 05:13
Hi Charles,

Change clrf TMR0IF to bcf INTCON,TMR0IF. Everything else looks OK.

Charles Linquis
- 11th January 2006, 23:39
That was it!

Thanks, Bruce.