;******************************************************************************
;Reset vector
; This code will start executing when a reset occurs.
;****************************************************************
ORG 0x0000
goto Main ;go to start of main code
ORG 0x0008
goto HighPr_ISR ;go to start of ISR
;****************************************************************
; Start of High Priority ISR
; rutina de servicio de interrupcion prioridad alta
;****************************************************************
HighPr_ISR
BSF LATA,4
INCF Tar_U,F
MOVFF Tar_U, LATD
BCF INTCON,INT0IF
RETFIE FAST
;******************************************************************************
;Start of main program
; The main program code is placed here.
;******************************************************************************
ORG 0x1000
Main
; Configuracion de puertos
MOVLW 0x0F
MOVWF ADCON1 ; Todos las AN como digitales
CLRF TRISA
SETF TRISB
CLRF TRISD
SETF TRISC
CLRF LATA
CLRF LATD
; Configuracion de interrupciones
BCF RCON,IPEN ; Deshabilito las prioridades
BCF INTCON2,INTEDG0 ; falling edge
MOVLW 0x50 ; PEIE + INT0E, INT0F = 0
MOVWF INTCON
BSF INTCON,GIE ; Activo interrupciones
INICIO
BTFSC PORTC,2
GOTO DIA
BTFSC PORTC,4
GOTO NOCHE
GOTO INICIO