#include 16C84.INC

	org	0

	goto	Start
	;--------------------
	org	4
	;--------------------

Start:
	page1
	movlw 	00000000B	; inicializace citace a prescaleru
	movwf	TMR0
	movlw 	00000000B	; konfigurace preruseni
	movwf	INTCON

	page1
	movlw	11110111B	; nastaveni portu na vstup nebo vystup
	movwf	PORTA		; 1=vstup 0=vystup
	movlw	11110111B
	movwf	PORTB

	bsf	TMR0, 7		; vypni pull-up na PORTB (OPTION registr)

	page0

	clrw			; vynulovani portu
	movwf	PORTA
	movwf	PORTB

	bsf	PORTA, 3	; Rozsvit LED

	bsf	PORTB, 3	; Pridrz napajeni

MainLoop:
	call	Delay250ms
	bcf	PORTB, 3	
	bcf	PORTA, 3	
	call	Delay250ms
	bsf	PORTB, 3	
	bsf	PORTA, 3	
 
	goto	MainLoop
	;---------------

;--- Spozdeni 250ms ----
Delay250ms:
	movlw	100		; 2,5 ms
	movwf	CT2
Delay250:
	movlw	250		; 2,5 ms
	movwf	CT1
	call	Delay10us

	decfsz	CT2, 1
	goto	Delay250
	return

;--- Spozdeni v nasobcich 10us ----
Delay10us:			; Prodleva (CT1 * 10us)+3us
	nop	
	nop
	nop
	nop
	nop
	nop
	nop
	decfsz	CT1, 1
	goto	Delay10us
	return

#include SERVO.INC

	end
