

		LIST P=PIC18F24K22
		#INCLUDE <P18F24K22.INC>

		CONFIG	FOSC=INTIO67, FCMEN=OFF, PLLCFG=OFF
		CONFIG	PRICLKEN=ON, IESO=OFF, PWRTEN=OFF
		CONFIG	BOREN=OFF, WDTEN=NOSLP, WDTPS=1024

		ORG	H'00'
		GOTO	START

		ORG H'08'
		GOTO	INT

		ORG	H'20'
START
		BSF		BAUDCON1,5
		BSF		IPR1,5
		MOVLW	H'C0'			;POVOLENI PRERUSENI
		MOVWF	INTCON
		MOVLW	H'20'			;PRERUSENI PRI PRIJMU
		MOVWF	PIE1
		MOVLW	H'FF'			;PORTC VYSTUP
		MOVWF	TRISC
		MOVLW	B'01100110'		;NASTAVENI INT OSCILATORU NA 8 MHZ
		MOVWF	OSCCON
		MOVLW	H'20'			;NASTAVENI PRIJMU
		MOVWF	TXSTA
		MOVLW	H'90'			;NASTAVENI VYSILANI
		MOVWF	RCSTA
		MOVLW	D'12'			;BAUD 9600
		MOVWF	SPBRG1


		CBLOCK	0x0000

		CAS1		;0 CASOVA SMYCKA
		CAS2		;1 CASOVA SMYCKA
		CAS3		;2 CASOVA SMYCKA
		VYS			;PROMENNA VYSILANI
		WBCK		;POMOCNA W
		SBCK		;POMOCNA STAT
		BBCK		;POMOCNA BSR
		REC

		ENDC
REP
			
		
		MOVLW	H'54'	;TO SI POSRAL
		MOVWF	VYS
		CALL	TRAN
		CALL	CAS

		MOVLW	H'4F'
		MOVWF	VYS
		CALL	TRAN
		CALL	CAS

		MOVLW	H'23'
		MOVWF	VYS
		CALL	TRAN
		CALL	CAS

		MOVLW	H'53'
		MOVWF	VYS
		CALL	TRAN
		CALL	CAS

		MOVLW	H'49'
		MOVWF	VYS
		CALL	TRAN
		CALL	CAS

		MOVLW	H'23'
		MOVWF	VYS
		CALL	TRAN
		CALL	CAS

		MOVLW	H'50'
		MOVWF	VYS
		CALL	TRAN
		CALL	CAS

		MOVLW	H'4F'
		MOVWF	VYS
		CALL	TRAN
		CALL	CAS

		MOVLW	H'53'
		MOVWF	VYS
		CALL	TRAN
		CALL	CAS

		MOVLW	H'52'
		MOVWF	VYS
		CALL	TRAN
		CALL	CAS

		MOVLW	H'41'
		MOVWF	VYS
		CALL	TRAN
		CALL	CAS

		MOVLW	H'4C'
		MOVWF	VYS
		CALL	TRAN
		CALL	CAS

		MOVLW	H'23'
		MOVWF	VYS
		CALL	TRAN
		CALL	CAS
		
		
		GOTO	REP


TRAN	MOVF	VYS,0
		MOVWF	TXREG
CHC		
		CLRWDT
		BTFSS	TXSTA,1
		GOTO	CHC
		RETURN	

		



CAS										;CASOVA SMYCKA 
		MOVLW	D'196'
		MOVWF	CAS3		
SEM3	MOVLW	D'40'
		MOVWF	CAS2
		
		CLRWDT		
		
SEM2	MOVLW	D'10'
		MOVWF	CAS1

		CLRWDT
SEM
		DECF	CAS1,1
		BTFSS	STATUS,2
		GOTO	SEM
		DECF	CAS2,1
		BTFSS	STATUS,2
		GOTO	SEM2
		DECF	CAS3,1
		BTFSS	STATUS,2
		GOTO	SEM3
		RETURN
INT									;PRERUSENI
		MOVWF	WBCK
		MOVFF	STATUS, SBCK
		MOVFF	BSR, BBCK

		MOVFF	RCREG1, REC
		MOVLW	H'55'
		MOVWF	TXREG
CHC1
		CLRWDT
		BTFSS	TXSTA,1
		GOTO	CHC1
		
		MOVFF	BBCK, BSR
		MOVF	WBCK,W
		MOVFF	SBCK, STATUS

		RETFIE	


END

		 	   