Prueva asi .
Codigo:
Inter
movwf w_temporal ; Guardas W
swapf STATUS, W
movwf s_temporal ; Guardas STATUS
movf PCLATH, W
movwf p_temporal ;Guardas PCLATH
; * Inhibir interrupciones
; Tu rutina de interrupcion
; Comprobar lo que quieras
; bla ,bla , bla
; * Activar interrupciones
movf p_temporal,w
movwf PCLATH ;Restauras PCLATH
swapf s_temporal,w
movwf STATUS ;Restauras STATUS
swapf w_temporal,f
swapf w_temporal,w ;Restauras W
retfie
Saludos .
Entonces parece que se pierde al producirse la interrupcion .
Creo que es esto mirandolo por encima .
Codigo:
ORG 0X00
goto INICIO
ORG 0X04
GOTO INTER
ORG 0X05
INICIO bsf STATUS,RP0 ;BANCO1
Fijate que pones ORG 0x4 ,, aqui tendrias que dejar un espacio de dos bytes ya y solo dejas el espacio de uno al poner ORG 0x5 . cambia ORG 0x5 por ORG 0x8 por ejemplo , o simplemente borra ORG 0x5
Este ejemplo funciona bien
Codigo:
INTERR
;interrupcode follows here
movwf wsave ; Save the W register
swapf STATUS, W
clrf STATUS ; Point to bank 0
movwf ssave ; Save the STATUS register
movf PCLATH, W ; Save PCLATH
movwf psave
movlw 0x16 ;restart timer from (256 + 12 + 4) - 250 => 4000 Hz (could need adjustment)
movwf TMR0
decfsz _i_tic_temp1,f
goto slutint
movlw 40 ;40 = 100Hz if using 4MHz
movwf _i_tic_temp1
decfsz _i_tic_temp2,f
goto slutint
movlw 10 ;10 = 10Hz if using 4MHz
movwf _i_tic_temp2
bsf _i_bits,0 ;sets bit0 of reg i_bits each 100ms
decfsz _i_tic,f
goto slutint
incf segundos,f
movlw 10 ;10 = 1Hz if using 4MHz (change to 20 for 8MHz and so on)
movwf _i_tic
movf segundos,w
sublw 60
btfss STATUS,Z ;check for 60 sec
goto slutint ;no
clrf segundos ;yes
incf minutos,f
movf minutos,w
sublw 60
btfss STATUS,Z ;check for 60 minutes
goto slutint ;no
clrf minutos ;yes
incf horas,f
movf horas,w
sublw 24
btfss STATUS,Z ;check for 24 hours
goto slutint ;no
clrf horas ;yes
slutint
bcf INTCON,2 ;zero tmr0 interrupt flag
; restorecode follows here
movf psave,w ;restore
movwf PCLATH
swapf ssave,w
movwf STATUS
swapf wsave,f
swapf wsave,w
retfie
y para activarla :
Codigo:
movlw low (32)
movwf INTCON ;"all interrupts off, enable tmr0int
bsf STATUS, RP0
movlw low (223)
movwf OPTION_REG ;"reset bit4 = internal clock to timer0
bcf STATUS, RP0
movlw low (250)
movwf TMR0
clrf horas
clrf minutos
clrf segundos
movlw low (10)
movwf _i_tic
movlw low (10)
movwf _i_tic_temp2
movlw low (40)
movwf _i_tic_temp1
movlw low (160)
movwf INTCON ; "interrupts on
con oscilador de 4Mhz .