Codigo Semáforo de Dos Vías_1 Pulsante

Embed Size (px)

Citation preview

  • 8/15/2019 Codigo Semáforo de Dos Vías_1 Pulsante

    1/4

    list p=16f84a ; listo el micro para usar#include P16F84A.inc ; incluye la libreria del microcontrolador a utilizar

     __CONFIG _FOSC_XT & _WDTE_OFF & _PWRTE_OFF & _CP_OFF ;CONFIGURA LA PALABRA del PIC;etiquetas de variablesPDel0 equ 0CPDel1 equ 0DPDel02 equ 0CPDel12 equ 0DLed equ 0; se defina la variable led como el bit cero de un registro ene ests caso port bPulsa equ 0; se define la variable pulsa como el bit 0, en este caso port aReset org 0x00; reinica en la primera direccion, aqui comienza el microcontrolador y se configura los puertosgoto Inicioorg 0x05; Origen del codigoInicio 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, RB3movwf TRISBbcf 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 ;; bsf PORTB,0; si esta en cero logico; CALL Mario; bcf PORTB,0;; btfss PORTA,1; goto Apagar;; bsf PORTB,1; CALL Mario

    ; bcf PORTB,1;; btfss PORTA,1; goto Apagar;

     bsf PORTB,0 bcf PORTB,1 bcf PORTB,2 bcf PORTB,3

  • 8/15/2019 Codigo Semáforo de Dos Vías_1 Pulsante

    2/4

     bcf PORTB,4 bsf PORTB,5 CALL Mario CALL Mario CALL Mario CALL Mario CALL Mario CALL Mario CALL Mario CALL Mario CALL Mario CALL Mario CALL Mario CALL Mario CALL Mario CALL Mario CALL 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 Mario CALL Mario CALL Mario

     CALL Mario CALL Mario CALL Mario CALL Mario CALL Mario CALL Mario CALL Mario CALL Mario CALL Mario CALL Mario CALL Mario CALL Mario 

    bcf PORTB,2 bsf PORTB,1 CALL Mario CALL Mario CALL Mario CALL Mario bsf PORTB,0 bcf PORTB,1 CALL Mario

  • 8/15/2019 Codigo Semáforo de Dos Vías_1 Pulsante

    3/4

     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 PORTB,0bcf PORTB,1bcf PORTB,2

    bcf PORTB,3bcf PORTB,4bcf 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, loopPDelL1 goto PDelL2 ; 2 ciclos delayPDelL2 goto PDelL3 ; 2 ciclos delayPDelL3 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

  • 8/15/2019 Codigo Semáforo de Dos Vías_1 Pulsante

    4/4

      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, loopPDelL12 goto PDelL22 ; 2 ciclos delayPDelL22 goto PDelL32 ; 2 ciclos delayPDelL32 clrwdt ; 1 ciclo delay 

    btfss PORTA,1  goto Apagar

     btfss PORTA,0 goto Bucle2

     return ; 2+2 Fin.

     end