Está en la página 1de 3

list p=16F84A #include <p16F84A.

inc> __CONFIG

; ; Incluye el PIC16F84A

_CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

;*---------------------- VARIABLES w f estado EQU cblock 0x0C PDel0 PDel1 PDel2 repeat repeaux endc ;*-----------------------------------------------------------------------ORG goto ORG main bsf 0x000 main 0x04 ; Reinicio del Procesador ; Ir a inicio del programa ;**Vector de interrupcin EQU EQU 0x03 0 1 ; w = guardar en w ; f = guardar en el registro

STATUS,RP0 movlw 0x1F movwf PORTA movlw 0x00 movwf PORTB bcf STATUS,RP0

;PA entradas ;PB salida

clrwdt ;*-----------------------------------------------------------------------clrf PORTB ;Borra el puerto swi0 btfsc PORTA,0 goto swi1 goto tempo0 PORTA,1 goto swi2 goto tempo1 PORTA,2 goto swi3 goto tempo2 PORTA,3 goto tempo4 goto tempo3 0x05 movwf goto 0x01 movwf repeat intreci repeat

swi1

btfsc

swi2

btfsc

swi3

btfsc

tempo4 movlw

tempo0 movlw

goto tempo1 movlw 0x02 movwf goto 0x03 movwf goto 0x04 movwf

intreci repeat intreci repeat intreci repeat

tempo2 movlw

tempo3 movlw

;*-----------------------------------------------------------------------intreci bcf bsf bsf call call call call bcf bsf call bcf call bsf call bcf call bsf call bcf call bcf bsf bsf call call call call bcf bsf call bcf call DEMORA PORTB,1 ;Apaga el Amarillo1 DEMORA DEMORA PORTB,4 ;Apaga el Amarillo2 DEMORA PORTB,4 ;Enciende el Amarillo2 DEMORA PORTB,4 ;Apaga el Amarillo2 DEMORA PORTB,4 ;Enciende el Amarillo2 DEMORA PORTB,4 ;Apaga el Amarillo2 DEMORA PORTB,0 ;Apaga el rojo 1 PORTB,2 ;Enciende el Verde1 PORTB,5 ;Enciende el Rojo2 PDelay PDelay PDelay PDelay PORTB,2 ;Apaga el verde1 PORTB,1 ;Enciende el Amarillo1 PORTB,5 ;Apaga el rojo2 PORTB,0 ;Enciende el rojo1 PORTB,3 ;Enciende el verde2 PDelay PDelay PDelay PDelay PORTB,3 ;Apaga el verde2 PORTB,4 ;Enciende el Amarillo2

bsf call bcf call bsf call bcf call goto

PORTB,1 ;Enciende el Amarillo1 DEMORA PORTB,1 ;Apaga el Amarillo1 DEMORA PORTB,1 ;Enciende el Amarillo1 DEMORA PORTB,1 ;Apaga el Amarillo1 DEMORA swi0

;*-----------------------------------------------------------------------PDelay movf repeat,w movwf repeaux PDelay1 movlw .239 ; 1 set number of repetitions (B) movwf PDel0 ; 1 | PLoop1 movlw .232 ; 1 set number of repetitions (A) movwf PDel1 ; 1 | PLoop2 clrwdt ; 1 clear watchdog PDelL1 goto PDelL2 ; 2 cycles delay PDelL2 goto PDelL3 ; 2 cycles delay PDelL3 clrwdt ; 1 cycle delay decfsz PDel1, 1 ; 1 + (1) is the time over? (A) goto PLoop2 ; 2 no, loop decfsz PDel0, 1 ; 1 + (1) is the time over? (B) goto PLoop1 ; 2 no, loop PDelL4 goto PDelL5 ; 2 cycles delay PDelL5 goto PDelL6 ; 2 cycles delay PDelL6 goto PDelL7 ; 2 cycles delay PDelL7 clrwdt ; 1 cycle delay decfsz repeaux,f goto PDelay1 return ; 2+2 Done ;*-----------------------------------------------------------------------DEMORA movlw .14 movwf PDel0 PLoop01 movlw .72 movwf PDel1 PLoop11 movlw .247 movwf PDel2 PLoop21 clrwdt decfsz PDel2, 1 goto PLoop21 decfsz PDel1, 1 goto PLoop11 decfsz PDel0, 1 goto PLoop01 PDelL11 goto PDelL21 PDelL21 clrwdt return end ; 1 set numero de repeticion (C) ; 1 | ; 1 set numero de repeticion (B) ; 1 | ; 1 set numero de repeticion (A) ; 1 | ; 1 clear watchdog ; 1 + (1) es el tiempo 0 ? (A) ; 2 no, loop ; 1 + (1) es el tiempo 0 ? (B) ; 2 no, loop ; 1 + (1) es el tiempo 0 ? (C) ; 2 no, loop ; 2 ciclos delay ; 1 ciclo delay ; 2+2 Fin.

También podría gustarte