LIST P=16F873A
	INCLUDE<P16F873A.INC>
	__CONFIG _PWRTE_ON & _WDT_OFF & _XT_OSC & _LVP_OFF
;...........................................................

 ORG 000

TMP0		EQU		20h
TMP1		EQU 	21h
TMP2		EQU		22h
	


LEDP		EQU		23h	
LEDL		EQU		24h
PIS3		EQU		25h
PIS4		EQU		26h
PIS31		EQU		27h
PIS6		EQU		28h
PIS7		EQU		29h
PIS8		EQU		2ah
PIS9		EQU		2bh
PIS10		EQU		2ch
PIS11		EQU		2eh
PIS12		EQU		2fh
PIS13		EQU		30h
PIS14		EQU		31h
;.....................................
#define	SL1		PORTC,0	;ČTENÍ U SLOUPCŮ
#define	SL2		PORTC,1	
#define	SL3		PORTC,2	
#define	SL4		PORTC,3	
#define	RA4		PORTC,4	;VÝSTUP ŘÁDKŮ V H
#define	RA5		PORTC,5
#define	RA6		PORTC,6
#define	RA7		PORTC,7
;....................................
#define	DIP		PORTA,0	;SPOUŠTĚNÍ ANOD DISPLEJE  PRAVÝ
#define	DIL		PORTA,1	;LEVÝ DISPL.
;...................................
#define	INFRA	PORTA,3
#define	OBRAZ	PORTB
;.................................
banksel TRISA
	movlw	B'00000000'
	movwf	TRISA

banksel TRISC

	movlw	B'00001111'		;KONFIGURACE VSTUPŮ-4-7
	movwf	TRISC

banksel TRISB
	movlw	B'00000000'
	movwf	TRISB
;.................................
		BCF	STATUS,RP0		; PRO NASTAVENÍ PORTU A JAKO DIGITÁLNÍ
		BCF	STATUS,RP1
		CLRF	PORTA
		BSF	STATUS,RP0
		MOVLW	0X06
		MOVWF	ADCON1
		MOVLW	B'11010000'
		MOVWF	TRISA
;...................................
	
	banksel	PORTA
;...................................
		MOVLW	.255	
		MOVWF	PORTA


		MOVLW	.255
		MOVWF	PORTB
	
		MOVLW	00h
		MOVWF	PORTC
		BCF		INFRA	
;................................


;......................
;	CLRF	
	MOVLW	.0
	MOVWF	LEDP
	MOVWF	LEDL
;	MOVLW	.255
;	MOVWF	SEDM
;..........................
;	MOVLW	.0
;	MOVWF	REG0
;	MOVWF	REGX
;..............................
;BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB


;WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
;.......................
	GOTO	START
;...............................
CAS		  MOVLW 0x1B  ;27 DEC 1000
        MOVWF TMP1
        MOVLW 0x0B  ;11 DEC
        MOVWF TMP0
        DECFSZ TMP0,F
        GOTO $-1
        DECFSZ TMP1,F
        GOTO $-5

		RETURN
;......................................
CAS2		MOVLW 0x7F  ;127 DEC 500000
        MOVWF TMP2
        MOVLW 0x0CF  ;207 DEC
        MOVWF TMP1
        MOVLW 0x05  ;5 DEC
        MOVWF TMP0
        DECFSZ TMP0,F
        GOTO $-1
        DECFSZ TMP1,F
        GOTO $-5
        DECFSZ TMP2,F
        GOTO $-9
		RETURN
;.....................................
TL1		MOVLW	.12
		MOVWF	LEDL	
;		BTFSC	SL1	
	;	GOTO	TL1
		
		RETURN
;..........
TL2		MOVLW	.33
		MOVWF	LEDP	
;		BTFSC	SL2	
;		GOTO	TL2
		
		RETURN

TL3		MOVLW	.28
		MOVWF	LEDL	
;		BTFSC	SL3	
;		GOTO	TL3
		
		RETURN

TLA		MOVLW	.123
		MOVWF	LEDP	
	;	BTFSC	SL4	
	;	GOTO	TLA
		
		RETURN

TL4		MOVLW	.250
		MOVWF	LEDL	
	;	BTFSC	SL1	
	;	GOTO	TL4
		
		RETURN

TL5		MOVLW	.240
		MOVWF	LEDP	
	;	BTFSC	SL2	
	;	GOTO	TL5
		
		RETURN

TL6		MOVLW	.255
		MOVWF	LEDP
		MOVWF	LEDL	
	;	BTFSC	SL3	
	;	GOTO	TL6
		
		RETURN

TLF		MOVLW	.255
		MOVWF	OBRAZ	
		BTFSC	SL4	
		GOTO	TLF
		
		RETURN	

TL7		MOVLW	.255
		MOVWF	OBRAZ	
		BTFSC	SL1	
		GOTO	TL7
		
		RETURN

TL8		MOVLW	.255
		MOVWF	OBRAZ	
		BTFSC	SL2	
		GOTO	TL8
		
		RETURN

TL9		MOVLW	.255
		MOVWF	OBRAZ	
		BTFSC	SL3	
		GOTO	TL9
		
		RETURN

TLB		MOVLW	.255
		MOVWF	OBRAZ	
		BTFSC	SL4	
		GOTO	TLB
		
		RETURN

TLE		MOVLW	.255
		MOVWF	OBRAZ	
		BTFSC	SL1	
		GOTO	TLE
		
		RETURN

TL0		MOVLW	.255
		MOVWF	OBRAZ	
		BTFSC	SL2	
		GOTO	TL0
		
		RETURN

TLD		MOVLW	.255
		MOVWF	OBRAZ	
		BTFSC	SL3	
		GOTO	TLD
		
		RETURN

TLC		MOVLW	.255
		MOVWF	OBRAZ	
		BTFSC	SL4	
		GOTO	TLC
		
		RETURN
;.....................................
SKEN	BSF	RA4
		BTFSC	SL1
		CALL	TL1
		BTFSC	SL2
		CALL	TL2
		BTFSC	SL3
		CALL	TL3
		BTFSC	SL4
		CALL	TLA
		BCF		RA4
;.........................
		BSF	RA5
		BTFSC	SL1
		CALL	TL4
		BTFSC	SL2
		CALL	TL5
		BTFSC	SL3
		CALL	TL6
		BTFSC	SL4
		CALL	TLF
		BCF		RA5
;..........................
		BSF	RA6
		BTFSC	SL1
		CALL	TL7
		BTFSC	SL2
		CALL	TL8
		BTFSC	SL3
		CALL	TL9
		BTFSC	SL4
		CALL	TLB
		BCF		RA6
;.....................
		BSF	RA7
		BTFSC	SL1
		CALL	TLE
		BTFSC	SL2
		CALL	TL0
		BTFSC	SL3
		CALL	TLD
		BTFSC	SL4
		CALL	TLC
		BCF		RA7
	RETURN	
	




;.....................................
	




START	BSF		DIP		;VYPNE BUZENÍ ANOD OBOU DISPLEJŮ
		BSF		DIL
HORE	MOVFW	LEDP
		MOVWF	OBRAZ	;PORTB
		BCF	DIP			;ANODY PRAVÉHO DISPLEJE ZAPLÉ	
		CALL	SKEN
		BSF	DIP		
;...........................
		MOVFW	LEDL
		MOVWF	OBRAZ
		BCF	DIL
		CALL	SKEN
		BSF	DIL
		GOTO	HORE
;..............................



		END

	
		
	
		








	


	