;BrunoF www.todopic.com.ar/foros
;Calibrado para 4Mhz.
LIST P=PIC16F84 ;Indicar PIC a utilizar
#include <P16F84.INC> ;Incluir fichero para utilizar el nombre de los registros SFR del PIC y demas cosas.
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC ;Configuracion de fuses:
ERRORLEVEL -302 ;Suprimir advertencias
PDel0 EQU 0x0C
PDel1 EQU 0x0D
PDel2 EQU 0x0E
SEGUNDOS EQU 0x0F
org 0x00
GOTO INICIO
INICIO
bsf STATUS,RP0 ;Banco 1
movlw 0xFF
movwf TRISA ;PUERTO A TODO COMO ENTRADA<0:4>
clrf PORTB ;PUERTO B TODO COMO SALIDA
bcf STATUS,RP0 ;Banco 0
ERRORLEVEL +302 ;Restaurar advertencias
clrf PORTB ;PUERTOB todo en bajo
btfss PORTA,4 ;Pregunta: ¿RA4 en alto?
goto $-1 ;No. Esperar
movlw .13 ;Si. Cargar 13 segundos en demora
bsf PORTB,0 ;pongo en alto la salida
call DEMORA ;Llamar a subrutina de demora
bcf PORTB,0 ;pongo en bajo la salida
goto INICIO ;Loop infinito(seguramente habra que modificar esto luego :D)
;///Subrutinas/////
DEMORA
movwf SEGUNDOS
DemSeg
movlw .14
movwf PDel0 ; 1 |
PLoop0 movlw .72 ; 1 set numero de repeticion (B)
movwf PDel1 ; 1 |
PLoop1 movlw .247 ; 1 set numero de repeticion (A)
movwf PDel2 ; 1 |
PLoop2 clrwdt ; 1 clear watchdog
decfsz PDel2, 1 ; 1 + (1) es el tiempo 0 ? (A)
goto PLoop2 ; 2 no, loop
decfsz PDel1, 1 ; 1 + (1) es el tiempo 0 ? (B)
goto PLoop1 ; 2 no, loop
decfsz PDel0, 1 ; 1 + (1) es el tiempo 0 ? (C)
goto PLoop0 ; 2 no, loop
decfsz SEGUNDOS,F ;Contar segundos
goto DemSeg ;Recargar variables
PDelL2 clrwdt ; 1 ciclo delay
return ; 2+2 Fin.
END