Handeling multiple Interrupts
	
	
		Hi people,
I have a 16f877 in which I am trying to use different interrupts for the timers.
My interrupt code is below but it wont do what I need. If I remove timer1 section then the timer0 section works and visa versa.
Can you see anything I have done wrong?
DEFINE	INTHAND	ROLLOVER
wsave		var	BYTE 	$020 SYSTEM
wsave1		var	BYTE 	$0a0 SYSTEM
wsave2		var	BYTE 	$120 SYSTEM
wsave3		var	BYTE 	$1a0 SYSTEM
ssave		var	BYTE 	BANK0 SYSTEM
psave		var	BYTE 	BANK0 SYSTEM
i_hour		var	BYTE
i_minu		var	BYTE
i_sec		var	BYTE
i_tic		var	BYTE
i_sec0		var	BYTE
i_tic0		var	BYTE
'PowerLed    var Portd.2
GOTO AFTERINT				'Jump past interrupthandler
asm
rollover
    movwf	wsave			
	swapf	STATUS, W		
	clrf	STATUS			
	movwf	ssave			
	movf	PCLATH, W		
	movwf	psave		
; interrupt code follows here 
    btfsc   PIR1,0 
    goto    timer1Interrupt
    btfsc   INTCON,2 
    goto    timer0Interrupt
    goto    restoreall
    
timer1Interrupt
;Timer 1
	movlw	0x58
	movwf	TMR1L
	movlw	0x9e			;restart timer from ffff - 9e58 => 5Hz if using 4MHz
	movwf	TMR1H
	decfsz 	_i_tic,f
	goto 	slutint1
	incf	_i_sec,f
	movlw	5			;5 = 1Hz if using 4MHz (change to 10 for 8MHz and so on)
	movwf	_i_tic
	movf	_i_sec,w
slutint1
	bcf	PIR1,0			;zero tmr1 interrupt flag
endasm
    if i_sec = 60 then
        i_sec = 0
    endif 
    toggle portd.2
asm
	goto    restoreall
timer0Interrupt
; Timer 0	
	movlw   00010000
    movwf   option_reg
    decfsz 	_i_tic0,f
	goto 	slutint2
	incf	_i_sec0,f
	movlw	1			;5 = 1Hz if using 4MHz (change to 10 for 8MHz and so on)
 	movwf	_i_tic0
	movf	_i_sec0,w 
slutint2
	bcf intcon,2
    bcf	PIE1,0			;zero tmr0 interrupt flag
endasm
    if i_sec0 = 60 then
        i_sec0 = 0
    endif 
    toggle portd.3
asm
    goto    restoreall
;end of interruptcode
; restorecode follows here
restoreall
	movf	psave,w			;restore
	movwf	PCLATH
	swapf	ssave,w
	movwf	STATUS
	swapf	wsave,f
	swapf	wsave,w
	retfie
endasm
AFTERINT:
INTCON = %00000000			'all interrupts off
PIR1 = %00000000			'zero tmr1 interrupt flag
PIE1 = %00000001			'enable timer1 interrupt
TMR1L = $58
TMR1H = $9e
i_sec = 0
i_sec0 = 0
i_tic = 5				    'this value should be the same as the value of line 8 in the ISR
i_tic0 = 5	
T1CON = %00110001			'timer1 on, prescaler=1/8
INTCON =  %11010000			'interrupt on
	 
	
	
	
		Now that I think about it
	
	
		Now that I think about it, skimask
The timer0 interrupt is the one not being delt with and not the other way around. If the tmr0 int happens more often then I would expect to see it happen and maybe miss the others.
Would you not agree?