Académique Documents
Professionnel Documents
Culture Documents
#include P16F84A.inc
; incluye la libreria del microcontrolador a utilizar
__CONFIG _FOSC_XT & _WDTE_OFF & _PWRTE_OFF & _CP_OFF ;CONFIGURA LA PALABRA del P
IC
;etiquetas de variables
PDel0 equ
0C
PDel1 equ
0D
PDel02 equ
0C
PDel12 equ
0D
Led equ 0; se defina la variable led como el bit cero de un registro ene ests ca
so port b
Pulsa equ 0; se define la variable pulsa como el bit 0, en este caso port a
Reset org 0x00; reinica en la primera direccion, aqui comienza el microcontrolad
or y se configura los puertos
goto Inicio
org 0x05; Origen del codigo
Inicio bsf STATUS,RP0 ; PASAMOS DEL BANCO CERO AL BANCO1
movlw b'11111' ; se mueve 11111 a w
movwf TRISA; Se Carga w en TRISA
movlw b'00000000' ; salida VA A SER RB0, RB1, RB2, RB3
movwf TRISB
bcf STATUS,RP0; SE PASA DEL BANCO 1 AL BANCO 0
bcf PORTB,0 ; comienza apagado
bcf PORTB,1
bcf PORTB,2
bcf PORTB,3
bcf PORTB,4
bcf PORTB,5
bcf PORTB,6
bcf PORTB,7
Bucle btfsc PORTA,0 ; se pregunta si esta en cero logico, si esta en cero salto
y si esta en 1 se mantiene
goto Apagar ; Si esta en 1 logico se apaga el led
Bucle2 btfss PORTA,1 ; se pregunta si esta en cero logico, si esta en cero salt
o y si esta en 1 se mantiene
goto Apagar ; Si esta en 1 logico se apaga el led
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
PORTB,0
PORTB,1
PORTB,2
PORTB,3
bcf PORTB,4
bsf PORTB,5
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
Mario
Mario
Mario
Mario
Mario
Mario
Mario
Mario
Mario
Mario
Mario
Mario
Mario
Mario
Mario
bsf PORTB,4
bcf PORTB,5
CALL Mario
CALL Mario
CALL Mario
CALL Mario
bcf PORTB,4
bsf PORTB,3
CALL Mario
bcf PORTB,0
bsf PORTB,2
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
CALL
Mario
Mario
Mario
Mario
Mario
Mario
Mario
Mario
Mario
Mario
Mario
Mario
Mario
Mario
Mario
bcf PORTB,2
bsf PORTB,1
CALL Mario
CALL Mario
CALL Mario
CALL Mario
bsf PORTB,0
bcf PORTB,1
CALL Mario
goto Bucle2
BucleNoche btfss PORTA,0
bcf PORTB,0
bsf PORTB,1
bcf PORTB,2
bsf PORTB,3
bcf PORTB,4
bcf PORTB,5
CALL Mario2
bcf PORTB,1
bcf PORTB,3
CALL Mario2
btfss PORTA,1
goto Apagar
goto BucleNoche
Apagar bcf
bcf
bcf
bcf
bcf
bcf
PORTB,0
PORTB,1
PORTB,2
PORTB,3
PORTB,4
PORTB,5
goto Bucle
Mario movlw
d'255'
; 1 set numero de repeticion (B)
movwf
PDel0
; 1 |
PLoop1 movlw
d'255'
; 1 set numero de repeticion (A)
movwf
PDel1
; 1 |
PLoop2 clrwdt
; 1 clear watchdog
clrwdt
; 1 ciclo delay
decfsz
PDel1, 1 ; 1 + (1) es el tiempo 0 ? (A)
goto
PLoop2
; 2 no, loop
decfsz
PDel0, 1 ; 1 + (1) es el tiempo 0 ? (B)
goto
PLoop1
; 2 no, loop
PDelL1 goto PDelL2
; 2 ciclos delay
PDelL2 goto PDelL3
; 2 ciclos delay
PDelL3 clrwdt
; 1 ciclo delay
btfss PORTA,1
goto Apagar
btfss PORTA,0
goto BucleNoche
return
; 2+2 Fin.
Mario2 movlw
d'127'
; 1 set numero de repeticion (B)
movwf
PDel02
; 1 |
PLoop12 movlw
d'127'
; 1 set numero de repeticion (A)
movwf
PDel12
; 1 |
PLoop22 clrwdt
; 1 clear watchdog
clrwdt
; 1 ciclo delay
decfsz
PDel12, 1 ; 1 + (1) es el tiempo 0 ? (A)
goto
PLoop22
; 2 no, loop
decfsz
PDel02, 1 ; 1 + (1) es el tiempo 0 ? (B)
goto
PLoop12
; 2 no, loop
PDelL12 goto PDelL22
; 2 ciclos delay
PDelL22 goto PDelL32
; 2 ciclos delay
PDelL32 clrwdt
; 1 ciclo delay
btfss PORTA,1
goto Apagar
btfss PORTA,0
goto Bucle2
return
end
; 2+2 Fin.