Semaforo
#include ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
;*****VARIABLE DEFINITIONS
w EQU 0 ; w=guardar en w
f EQU 1 ; f=guardar en el registro
estado EQU 0x03
cblock 0x0C
PDel0
PDel1
PDel2
repeat
repeaux
endc;**********************************************************************
ORG 0x000 ; processor reset vector
goto main ; go to beginning of program
ORG 0x04;**Vector de interrupción
main bsf STATUS,RP0
movlw 0x1F
movwf PORTA ;PA entradas
movlw 0x00
movwf PORTB ;PB salida
bcf STATUS,RP0
clrwdt;***************************************************************************
clrf PORTB ;Borra el puerto
swi0 btfsc PORTA,0
goto swi1
goto tempo0
swi1 btfsc PORTA,1
goto swi2
goto tempo1
swi2btfsc PORTA,2
goto swi3
goto tempo2
swi3 btfsc PORTA,3
goto tempo4
goto tempo3
tempo4 movlw 0x05
movwf repeat
goto intreci
tempo0 movlw 0x01
movwf repeat
goto intrecitempo1 movlw 0x02
movwf repeat
goto intreci
tempo2 movlw 0x03
movwf repeat
goto intreci
tempo3 movlw 0x04
movwf repeat;*************************************************************
intreci bcf PORTB,5 ;Apaga el rojo2
bsf PORTB,0 ;Enciende el rojo1
bsf PORTB,3 ;Enciende el verde2
call PDelay
call PDelay
call PDelay
call PDelay
bcf PORTB,3 ;Apagael verde2
bsf PORTB,4 ;Enciende el Amarillo2
call DEMORA
bcf PORTB,4 ;Apaga el Amarillo2
call DEMORA
bsf PORTB,4 ;Enciende el Amarillo2
call DEMORA
bcf PORTB,4;Apaga el Amarillo2
call DEMORA
bsf PORTB,4 ;Enciende el Amarillo2
call DEMORA
bcf PORTB,4 ;Apaga el Amarillo2
call DEMORA
bcf PORTB,0 ;Apaga el rojo 1
bsf...
Regístrate para leer el documento completo.