;**************************************************************************
INIT	
	movlw	b'000000'
	movwf	PORTA
	movlw	b'00000000'
	movwf	PORTB
	movlw	b'00000000'
	movwf	PORTC
	movlw	b'00000000'	; přednastavení PORTu D
	movwf	PORTD		; !!! jen PIC16F874 a PIC16F877 !!!
	movlw	b'000'		; přednastavení PORTu E
	movwf	PORTE		; !!! jen PIC16F874 a PIC16F877 !!!
;       ------------------------
	bcf	STATUS,RP1
	bsf	STATUS,RP0	; banka registru 1
	movlw	b'00000110'	; A/D input OFF
	movwf	ADCON1

	movlw	b'000000'	; portA 5-0, (0=vystup, 1=vstup)
	movwf	TRISA

	movlw	b'00000100'	; PULL-UPy OFF, preddelic=1:32 pripojen k TMR0
	movwf	OPTION_REG	; f:4  :32  :256 = 122,1Hz (8,192ms)
	movlw	b'00001111'	; portB 7-0, (0=vystup, 1=vstup)
	movwf	TRISB
	movlw	b'00000000'	; portC 7-0, (0=vystup, 1=vstup)
	movwf	TRISC

	movlw	b'10000000'	; portD 7-0 (0=vystup, 1=vstup)
	movwf	TRISD		; !!! jen PIC16F874 a PIC16F877 !!!

	movlw	b'00000000'		; portE 2-0 (0=vystup, 1=vstup)
	movwf	TRISE		; !!! jen PIC16F874 a PIC16F877 !!!

	bcf	STATUS,RP0	; banka registru 0


;       ------------------------ 	
;Vynulovat registry displeje
;at program nebloudi hned na zacatku
;PRO JISTOTU
	clrf	DISPOR
	movlw	0x0D
	movwf	DIS0
	movwf	DIS1
	movwf	DIS2
	movwf	DIS3
	movwf	DIS4
	movwf	DIS5
	movwf	DIS6
	movwf	DIS7
	movwf	Priznak
	movlw	.2
	movwf	TMP_PS1		; 250msregistry
	movwf	TMP_PS2		; 500ms
	movwf	TMP_PS3		; 2sec
;	movlw	.10
	movwf	TMP_PS4		; 10sec
	
	
;init TMR1

	movlw	b'00000000'
	movwf	T1CON
	banksel	PIE1
	bsf		PIE1,TMR1IE
	banksel	0
	
	bsf	INTCON,T0IE	; 1=povoleno přerušení při přetečení TMR0
	bcf	INTCON,INTE	; 1=povoleno přerušení z portu RB0/INT
	bsf	INTCON,GIE	; 1=povolena všechna nemaskovaná přerušení
	bsf	INTCON,PEIE

;Nastaveni PWM
	banksel	PR2
	movlw	.255
	movwf	PR2
	banksel	0
	pagesel	Read_Jas
	call	Read_Jas
	banksel	CCPR1L
	movwf	CCPR1L
	banksel	0
	
	movlw	b'00000111'	
	movwf	T2CON		

	movlw	b'00001111'	
	movwf	CCP1CON

;init VFD
	pagesel	INIT_VFD
	call	INIT_VFD
	call	TESTVFD
	
;test pripojeneho cidla
	pagesel	TEST
	call	TEST
	pagesel	0
;inicializace zarizeni
	pagesel	INIT_DS1320
	call	INIT_DS1320
;Prednastaveni DS1302
	pagesel	Read_Alarm
	call	Read_Alarm
	banksel	0
	pagesel	0
	bsf	AL_ON	;Alarm ON
	movlw	.5
	movwf	TMP_PS4
	bcf	sec10	