init_adc:			
	ldi		tmp1,0	;channel0 first
	out		admux,tmp1		
	ldi		tmp1,prescaler_adc
	out		adcsr,tmp1	
	sbi		adcsr,aden	;ADC enabled
	sbi		adcsr,adsc	;start first conversion	
	ret			

get_adc:
	sbis	adcsr,adif	;if current conversion 
	ret					;not redy exit
	in		op1l,admux	;else get current channel
	andi	op1l,0b00000111
	get_adr	op1l,buf_adc
	in		tmp1,adcl	;get AD conversion result
	in		tmp2,adch
	st		x+,tmp2		;and store it
	st		x,tmp1
	inc		op1l
	cpi		op1l,ad_maxch+1; if new channel number
	brlo	getadc1		;is overflow
	clr		op1l		; back to first channel
getadc1:
	out		admux,op1l	;init adc mux
	sbi		adcsr,adsc	;start a new convertion
	ret


