	LIST P=16F88
	#include <p16f88.inc>




	__CONFIG    _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_ON & _PWRTE_OFF & _WDT_OFF & _INTRC_CLKOUT

;Program Configuration Register 2
	__CONFIG    _CONFIG2, _IESO_OFF & _FCMEN_OFF

	cblock	0x20
	TMP0
	endc




	ORG 0
	GOTO START

	ORG 4
	GOTO START

START
	BANKSEL   STATUS
	CLRF    STATUS

	BANKSEL   OSCCON
	BSF 	OSCCON,IRCF2   ;KMITOCET 8 Mhz
	BSF 	OSCCON,IRCF1
	BSF 	OSCCON,IRCF0

	BANKSEL   ANSEL
	MOVLW   B'00000001' ;Pin RA0/AN0 analogovy vstup
	MOVWF   ANSEL
	MOVLW   B'00000000'
	MOVWF   OPTION_REG

   BANKSEL   ADRESL   ;vymazanie registrov prevodu
   CLRF   ADRESL
   BANKSEL   ADRESH
   CLRF   ADRESH

	BANKSEL   TRISB
	MOVLW    B'00000000'
	MOVWF    TRISB      ;B-port ako vystupny
	MOVLW    B'11111111'
	MOVWF    TRISA

	BANKSEL   PORTB
	CLRF   PORTB
	CLRF   PORTA
;nastaveni AD
	BANKSEL   ADCON1
	MOVLW   B'10000000'   ;radenie sprava, casovanie AD, AVdd-AVss
	MOVWF   ADCON1
	BANKSEL   ADCON0
	MOVLW   B'11000001'   ;Frc, 000-1 vstup AD na AN0, stav 0, AD zapnuty
	MOVWF   ADCON0
	
	banksel	PORTB
	bsf		PORTB,0			;TEST
;	GOTO    PROGRAM

PROGRAM


;	BANKSEL	ADCON0
	BSF		ADCON0,GO  	;zapnuti AD
	BTFSC	ADCON0,GO   ;cakanie na ukoncenie prevodu
	GOTO	$-1

	BANKSEL		ADRESL      
	MOVF		ADRESL,W   ;Adresl do pracovneho reg.
	BANKSEL		PORTB      
	MOVWF		PORTB      ;Pracovny do portu B.
	
	GOTO		PROGRAM

;CEK40us   ;Delay 40 cycles
;        MOVLW 0x0D  ;13 DEC
;        MOVWF TMP0
;        DECFSZ TMP0,F
;        GOTO $-1
;   RETURN


	END




