LIST P=16F877 
INCLUDE<P16F877.INC> 
 __CONFIG _PWRTE_OFF & _WDT_OFF & _XT_OSC & _LVP_OFF 

; // Inputs 
#DEFINE INT_LED PORTB,5      ; Senzor cilindru 1 

; // Outputs 
;#DEFINE SIREN PORTB,1      ; Výstup pro sirénu (maják) 

; Registry pro Časové odpočty 
 cblock   20h
CISLO  
CISLOA    
CISLOB    
CISLOC   
 endc

;************************************************************************************************************
    ORG         0H
    GOTO        INIT
    ORG         4H
    nop             

INIT   CLRWDT            
       BANKSEL   TRISA               ;Nastavení banky 1 
       CLRF      TRISA               ;Přesunutí z registru W do registru TRISA (Dochází k nastavení portů vstupně-výstupních pinů) 
       CLRF      TRISB               ;Přesunutí z registru W do registru TRISA (Dochází k nastavení portů vstupně-výstupních pinů) 
       MOVLW     6                   ; Configure all pins 
       MOVWF     ADCON1              ; as digital inputs 
       BANKSEL   PORTA
       CLRF      PORTA ; Initialize PORTA by 
 
  
START  CLRWDT
       BSF       INT_LED 
       CALL      WAIT_1000 
       BCF       INT_LED 
       CALL      WAIT_1000 
       GOTO START 


; ---------------------------------- TIMER ZONE ---------------------------------- 
WAIT_200   CLRF CISLO 
POINT_200    INCFSZ CISLO,1 
         GOTO POINT_200 
         INCFSZ CISLOA,1 
         GOTO POINT_200 
         RETURN 

WAIT_500   CALL WAIT_200 
         CALL WAIT_200 
         RETURN          
          
WAIT_1000   CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         RETURN 

WAIT_2000   CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         RETURN 
          
WAIT_3000   CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         RETURN 
          
WAIT_4000   CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         RETURN 
          
WAIT_5000   CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         RETURN 
          
WAIT_10000   CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         CALL WAIT_200 
         RETURN 
       
END