fallas de programacion(mplab) del proyecto semaforos con sensores con pic16f877a

bueno que tal amigos, tengo un inconveniente, mi proyecto es una secuencia de semaforos con sensores (lo estoy reemplazando con pulsadores), cuando realizo la compilacion todo parece bien,ya que no me vota errores. Sin embargo, al probarlo en el isis proteus no sigue la secuencia(se enciende la luz verde del semaforo1 y la roja del semaforo2 y nada mas) ;y no me explico por que. Agradeceria que me respondan la inquietud.

PD: Dejo la imagen del proteus y la programacion que esta en ams (mplab).


HTML:
;Programa de 2 semaforos con sensores
;Un sensor para cada semaforo. 
;Cuando se activa un sensor (no hay autos) 
;Entradas: Puerto B (RB4 y RB4) mediante interrupciones 
;Salidas:  Puerto B (RB0-RB5)
;		   RB0=Verde1, RB1=Ambar1, RB2=Rojo1
;	;---------------------------------------------------------------

include	"p16f877a.inc"
LIST		P=16f877a

__CONFIG _CP_OFF & _CPD_OFF & _LVP_OFF & _WDT_OFF & _XT_OSC

	   RB3=Verde2, RB4=Ambar2, RB5=Rojo2
TIME	equ		0x0C
COUNT1	equ		0x0D
COUNT2	equ		0x0E
COUNT3	equ		0x0F
TEMP	equ		0x10
TEMP2	equ		0x11

		org		0x00		; Inicio de programa
		goto	BEGIN
		org		0x04		; Inicio de rutina de interrupcion
		movwf	TEMP		; Salva el registro W
		movf	STATUS,0	
		movwf	TEMP2		; Salva el estado de los flags
VERIF1:	btfss	PORTB,4		; Procedimiento si se activa RB4
		goto	VERIF2
		movlw	0x19		; Verificar TIME<25
		subwf	TIME,0
		btfsc	STATUS,0	; Finalizar si TIME>25 segundos
		goto	FININT
		movlw	0x18		; Si TIME<25 segundos
		movwf	TIME		; Preestablecer TIME=24
		goto	FININT		
VERIF2:	btfss	PORTB,5		; Procedimiento si se activa RB5
		goto	FININT
		movlw	0x1F		; Verificar TIME>30
		subwf	TIME,0
		btfss	STATUS,0	; Finalizar si TIME<30 segundos
		goto	FININT
		movlw	0x37		; verificar TIME<55
		subwf	TIME,0
		btfsc	STATUS,5
		goto 	FININT
		movlw	0x36		; Si TIME<55 segundos
		movwf	TIME		; Preestablecer TIME=54
FININT:	
		movf	PORTB,0		; Necesario para habilitar interrupciones
		bcf	INTCON,0	; Permitir interrupciones
		movf	TEMP2,0
		movwf	STATUS		; Restaura estado de flags
		movf	TEMP,0
		retfie				; Retorno de Interrupcion

							; Principal
BEGIN:	             bsf	INTCON,7	; Habilitacion global de interrupciones
		bsf	INTCON,3	; Interrupciones por puerto B (RB4-RB7)
		bcf	INTCON,0	; Permitir interrupciones
		bsf	STATUS,5	; Inicio configuracion E/S
		clrf	PORTA		; Puerto A como salida
		movlw	0xF0		
		movwf	PORTB		; RB0-RB2 como salidas y RB4-RB7 como entradas
		bcf	STATUS,5	; Fin configuracion E/S
		clrf	TIME
		movlw	0x01		; b'00000001'
		movwf	PORTA		
		movlw	0x04		; b'00000100'
		movwf	PORTB		; RA0=Verde1 y RB2=Rojo2
LOOP:	             movlw	0xFA   		; Inicio rutina para que TIME se incremente
		movwf	COUNT1		; cada 1 segundo
		movlw	0xC8		; para cristal de 10 MHz
		movwf	COUNT2
		movlw	0x12	
		movwf	COUNT3		

LOOP1:	             decfsz	COUNT1,1
		goto	LOOP1
		movlw	0xFA
		movwf	COUNT1
		decfsz	COUNT2,1
		goto	LOOP1
		movlw	0xFA
		movwf	COUNT1
		movlw	0xC8
		movwf	COUNT2
		decfsz	COUNT3,1
		goto	LOOP1		
		incf	TIME,1
		movlw	0x3C	
		subwf	TIME,0
		btfsc	STATUS,2	; borrar TIME cuando llegue a 60 segundos
		clrf	TIME		; Fin de rutina TIME
		movlw	0x00		; 0 segundos
		subwf	TIME,0
		btfsc	STATUS,2	; si TIME=0 segundos saltar a FIRST
		goto	FIRST
		movlw	0x19		; 25 segundos
		subwf	TIME,0
		btfsc	STATUS,2	; Si TIME=25 segundos saltar a SECOND
		goto	SECOND
		movlw	0x1E		; 30 segundos
		subwf	TIME,0
		btfsc	STATUS,2	; Si TIME=30 segundos saltar a THIRD
		goto	THIRD
		movlw	0x37		; 55 segundos
		subwf	TIME,0
		btfsc	STATUS,2	; Si TIME=55 segundos saltar a FOURTH
		goto	FOURTH
		goto	FINISH
FIRST:	             bsf	INTCON,7	; Habilitacion global de interrupciones 
		movlw	0x01		; b'00000001'
		movwf	PORTA
		movlw	0x04		; b'00000100'
		movwf	PORTB		; RA0=Verde1 y RB2=Rojo2
		goto	FINISH
SECOND:  	bcf	INTCON,7	; Deshabilitar interrupciones en Ambar
		movlw	0x02		; b'00000010'
		movwf	PORTA		; RA1=Ambar1 y RB2=Rojo2
		goto	FINISH
THIRD:	             bsf	INTCON,7	; Habilitacion global de interrupciones

		movlw	0x04		; b'00000100'
		movwf	PORTA
		movlw	0x01		; b'00000001'
		movwf	PORTB		; RA2=Rojo1 y RB0=Verde2
		goto	FINISH
FOURTH:	             bcf	INTCON,7	; Deshabilitar interrupciones en Ambar
		movlw	0x02		; b'00000010'
		movwf	PORTB		; RA2=Rojo1 y RB1=Ambar2
FINISH:	             goto	LOOP

		end					; Fin de Prograna








URL]
 
Atrás
Arriba