Académique Documents
Professionnel Documents
Culture Documents
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _HS_OSC &
_WRT_OFF & _LVP_OFF & _CPD_OFF
;**********************************************************************
ORG 0x000 ; processor reset vector
goto Interrupcion
Salir_Int:
movf pclath_temp,w ; retrieve copy of PCLATH register
movwf PCLATH ; restore pre-isr PCLATH register contents
movf status_temp,w ; retrieve copy of STATUS register
movwf STATUS ; restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ; restore pre-isr W register contents
retfie ; return from interrupt
main
clrf PORTD
bsf STATUS,RP0
bcf STATUS,RP1 ; Banco 1
clrf TRISD ; PORTD Salida
movlw 0xFF
movwf TRISB ; PORTB Entrada
;Configurar el OPTION_REG
movlw b'10000111'
movwf OPTION_REG
bcf STATUS,RP0
bcf STATUS,RP1 ; Banco 0
;Activar Interrupcion
bsf INTCON,GIE ; GIE=1
bsf INTCON,T0IE ; TMR0=1
;Cargar TMR0
movlw .60
movwf TMR0
PP:
bcf PORTD,0
call Delay_100ms
bsf PORTD,0
call Delay_100ms
goto PP
Interrupcion:
btfsc INTCON,T0IF
goto Int_TMR0
goto Salir_Int
Int_TMR0:
movlw .60
movwf TMR0
btfss PORTD,1
goto Hacer1_D1
goto Hacer0_D1
Hacer1_D1:
bsf PORTD,1
goto Salir_Int_TMR0
Hacer0_D1:
bcf PORTD,1
goto Salir_Int_TMR0
Salir_Int_TMR0:
bcf INTCON,T0IF
goto Salir_Int
#include "ModDelay_20M.asm"
Delay_100ms:
call Delay_50ms
call Delay_50ms
return
Delay_50ms:
call Delay_10ms
call Delay_10ms
call Delay_10ms
call Delay_10ms
call Delay_10ms
return
Delay_10ms:
movlw d'67'
movwf CONTA1
bucle1:
movlw d'250'
movwf CONTA2
bucle2:
decfsz CONTA2,F
goto bucle2
decfsz CONTA1,F
goto bucle1
return