;***** DEFINICIÓN DE VARIABLES ****************************************
variables UDATA 0x110
w_temp RES 1; Variables para la salvaguarda del contexto
pclath_temp RES 1
status_temp RES 1
reg_temp RES 1
;******** VECTORES DE INTERRUPCIÓN *************************************
RESET_VECT CODE 0x000 ; Vector de reset del procesador
nop ; "nop"
pagesel inicio ;
goto inicio ; Salto al inicio del programa
;*******************************************************************
INT_VECTOR CODE 0x004 ; Zona del vector de interrupción
goto ServInt ;
ISR CODE 0x005
ServInt:
banksel w_temp
movwf w_temp
movf STATUS,w
movwf status_temp ;hasta aquí guarda de registros
btfsc INTCON,INTF ;¿ocurrió flanco en rb0?
goto noint
movlw b'00110100' ; indicar interrupción
banksel PORTB
movwf PORTB
bcf INTCON,INTF
; Limpia las interrupciones pendientes
noint
banksel status_temp ; recupera lo guardado
movf status_temp,w
movwf STATUS
swapf w_temp,f
swapf w_temp,w
retfie ;
;***** PROGRAMA PRINCIPAL *********************************************
MAIN CODE ; Zona de Programa
inicio:
bcf INTCON,GIE ;Deshabilito por si acaso
movlw b'00001001' ;
banksel TRISB ; configurando el puerto B
movwf TRISB
movlw b'00000000' ;
banksel PORTB
movwf PORTB
bsf INTCON,INTE ;
banksel OPTION_REG ;
bsf OPTION_REG,INTEDG;
bsf INTCON,GIE ;
bcf INTCON,1; Limpia las interrupciones pendientes
goto $ ; espera interrupciones
fin
END